1 | <?php |
||
16 | class Request { |
||
17 | |||
18 | /** |
||
19 | * Host to make the calls to |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | private $host = "https://api.pinterest.com/v1/"; |
||
24 | |||
25 | /** |
||
26 | * Access token |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $access_token = null; |
||
31 | |||
32 | /** |
||
33 | * Instance of the CurlBuilder class |
||
34 | * |
||
35 | * @var CurlBuilder |
||
36 | */ |
||
37 | private $curlbuilder; |
||
38 | |||
39 | /** |
||
40 | * Array with the headers from the last request |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | private $headers; |
||
45 | |||
46 | /** |
||
47 | * Constructor |
||
48 | * |
||
49 | * @param CurlBuilder $curlbuilder |
||
50 | */ |
||
51 | 37 | public function __construct(CurlBuilder $curlbuilder) |
|
52 | { |
||
53 | 37 | $this->curlbuilder = $curlbuilder; |
|
54 | 37 | } |
|
55 | |||
56 | /** |
||
57 | * Set the access token |
||
58 | * |
||
59 | * @access public |
||
60 | * @param string $token |
||
61 | * @return void |
||
62 | */ |
||
63 | 37 | public function setAccessToken($token) |
|
67 | |||
68 | /** |
||
69 | * Make a get request to the given endpoint |
||
70 | * |
||
71 | * @access public |
||
72 | * @param string $endpoint |
||
73 | * @param array $parameters |
||
74 | * @return Response |
||
75 | */ |
||
76 | 25 | public function get($endpoint, array $parameters = array()) |
|
86 | |||
87 | /** |
||
88 | * Make a post request to the given endpoint |
||
89 | * |
||
90 | * @access public |
||
91 | * @param string $endpoint |
||
92 | * @param array $parameters |
||
93 | * @return Response |
||
94 | */ |
||
95 | 3 | public function post($endpoint, array $parameters = array()) |
|
99 | |||
100 | /** |
||
101 | * Make a delete request to the given endpoint |
||
102 | * |
||
103 | * @access public |
||
104 | * @param string $endpoint |
||
105 | * @param array $parameters |
||
106 | * @return Response |
||
107 | */ |
||
108 | 5 | public function delete($endpoint, array $parameters = array()) |
|
112 | |||
113 | /** |
||
114 | * Make an update request to the given endpoint |
||
115 | * |
||
116 | * @access public |
||
117 | * @param string $endpoint |
||
118 | * @param array $parameters |
||
119 | * @return Response |
||
120 | */ |
||
121 | public function update($endpoint, array $parameters = array()) |
||
125 | |||
126 | /** |
||
127 | * Return the headers from the last request |
||
128 | * |
||
129 | * @return array |
||
130 | */ |
||
131 | 2 | public function getHeaders() |
|
135 | |||
136 | /** |
||
137 | * Execute the http request |
||
138 | * |
||
139 | * @access public |
||
140 | * @param string $method |
||
141 | * @param string $apiCall |
||
142 | * @param array $parameters |
||
143 | * @param array $headers |
||
144 | * @return Response |
||
145 | */ |
||
146 | 33 | public function execute($method, $apiCall, array $parameters = array(), $headers = array()) |
|
220 | |||
221 | } |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: