-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzermelo.php
71 lines (62 loc) · 1.89 KB
/
zermelo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?PHP
error_reporting(1); ini_set('display_errors', 1);
/*
* De code voor deze Zermelo API wrapper valt verder te vinden in
* ./import/zermelo-api.php
*/
require_once("import/nogit.php");
require_once("import/zermelo-api.php");
$zermeloAPI = new Zermelo();
$zermeloAPI->setSchool($zermeloSchool);
$zermeloAPI->setApiToken($zermeloApiToken);
$zermeloAPI->setBranchOfSchool($zermeloBranchOfSchool);
header('Content-Type: text/html; charset=utf-8');
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$data = array();
$data["type"] = "error";
$data["message"] = "Unknown error";
$data["data"] = array();
function returnError($msg) {
global $data;
$data["type"] = "error";
$data["message"] = $msg;
$data["data"] = array();
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);
die();
}
function returnWarning($msg) {
global $data;
$data["type"] = "warning";
$data["message"] = $msg;
$data["data"] = array();
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);
die();
}
function returnData($msg, $stuff) {
global $data;
$data["type"] = "success";
$data["message"] = $msg;
$data["data"] = $stuff;
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);
die();
}
if (isset($_GET["allvalid"])) {
// alleen voor debuggen!
$appointments = $zermeloAPI->getAllAppointments();
}
else {
$appointments = $zermeloAPI->getAppointments();
}
$appointmentCount = count($appointments);
if ($appointmentCount > 0) {
returnData($appointmentCount . " lesuren gevonden", $appointments);
}
else {
returnData("0 lesuren gevonden", array());
}
?>