-
Notifications
You must be signed in to change notification settings - Fork 5
/
request.php
84 lines (69 loc) · 1.72 KB
/
request.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
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
class Request
{
private $request_vars;
private $data;
private $http_accept;
private $method;
private $ID;
public function __construct($id = null)
{
$this->request_vars = array();
$this->data = array();
$this->http_accept = 'application/json';
$this->method = 'get';
$this->ID = $id;
$this->processRequest();
}
public function processRequest()
{
$request_method = strtolower($_SERVER['REQUEST_METHOD']);
$this->setMethod($request_method);
$request_vars = $_GET;
if($request_vars != ''){
$this->setRequestVars($request_vars);
}
$data = file_get_contents('php://input');
if($data != ''){
$this->setData(json_decode($data,TRUE));
}
}
public function setID($id)
{
$this->ID = $id;
}
public function setData($data)
{
$this->data = $data;
}
public function setMethod($method)
{
$this->method = $method;
}
public function setRequestVars($request_vars)
{
$this->request_vars = $request_vars;
}
public function getID()
{
return $this->ID;
}
public function getData()
{
return $this->data;
}
public function getMethod()
{
return $this->method;
}
public function getHttpAccept()
{
return $this->http_accept;
}
public function getRequestVars()
{
$this->request_vars['id'] = $this->ID;
return $this->request_vars;
}
}
?>