This repository has been archived by the owner on Jun 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAPI.class.php
69 lines (56 loc) · 1.45 KB
/
API.class.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
<?php
/**
* Created by PhpStorm.
* User: Arthur
* Date: 13-1-2017
* Time: 14:01
*/
class API {
private $web;
private $token;
public $raw;
function __construct(web $web, $token = null)
{
$this->web = $web;
if ($token != null) {
$this->token = $token;
}
}
public function login($username, $password) {
$url = "https://sah.ownprojects.info/login";
$variables = array("post" => "email=$username&password=$password");
$data = json_decode($this->web->post($url, $variables));
$this->raw = $this->web->getResponse();
if (isset($data->token)) {
$this->setToken($data->token);
return true;
}
return false;
}
public function loggedIn() {
$url = "https://sah.ownprojects.info/ingelogd?token=".$this->getToken();
$response = $this->web->get($url);
$loggedIn = json_decode($response);
if (isset($loggedIn->ingelogd)) {
return ($loggedIn->ingelogd == "false") ? false : true;
} else {
return false;
}
}
public function getPrikbordItems() {
$url = "https://sah.ownprojects.info/prikbord_actueel?token=".$this->getToken();
$response = $this->web->get($url);
$prikbordItems = json_decode($response);
return $prikbordItems;
}
public function denyPrikbordItem($id) {
$url = "https://sah.ownprojects.info/prikbord_kan_niet?token=".$this->getToken()."&id=$id";
$response = $this->web->get($url);
}
public function getToken() {
return $this->token;
}
public function setToken($token) {
$this->token = $token;
}
}