@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | |
45 | 45 | $rpath = realpath($fname); |
46 | 46 | |
47 | - $fp=fopen(realpath($fname),"r"); |
|
47 | + $fp = fopen(realpath($fname), "r"); |
|
48 | 48 | |
49 | - $url = self::$baseUrl.$options['url'] . '?' . http_build_query(array_merge( |
|
50 | - array( 'api_key' => self::getApiKey()), $query) |
|
49 | + $url = self::$baseUrl.$options['url'].'?'.http_build_query(array_merge( |
|
50 | + array('api_key' => self::getApiKey()), $query) |
|
51 | 51 | ); |
52 | 52 | |
53 | 53 | //self::simplePrint($body);die(""); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | //echo "code = $code <br>"; |
82 | 82 | $json = json_decode($result, true); |
83 | 83 | //var_dump($json); die(""); |
84 | - if (200 == $code) { |
|
84 | + if (200==$code) { |
|
85 | 85 | return $json; |
86 | 86 | } elseif (isset($json['errors'])) { |
87 | 87 | throw new ApiError(implode(', ', $json['errors'])); |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | public static function makeRequst($options) { |
94 | 94 | $errorHandler = new myErrorHandler(); |
95 | 95 | |
96 | - $old_error_handler = set_error_handler(array( $errorHandler, "proc_error")); |
|
96 | + $old_error_handler = set_error_handler(array($errorHandler, "proc_error")); |
|
97 | 97 | $method = isset($options['method']) ? $options['method'] : 'GET'; |
98 | 98 | $query = isset($options['query']) ? |
99 | 99 | array_filter($options['query']) : array(); |
@@ -106,26 +106,26 @@ discard block |
||
106 | 106 | ); |
107 | 107 | |
108 | 108 | if (isset($options['HTTPHEADER'])) { |
109 | - $headers[]=$options['HTTPHEADER']; |
|
109 | + $headers[] = $options['HTTPHEADER']; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | if (isset($options['HTTPHEADERS'])) { |
113 | - foreach ($options['HTTPHEADERS'] As $header) $headers[]=$header; |
|
113 | + foreach ($options['HTTPHEADERS'] As $header) $headers[] = $header; |
|
114 | 114 | } |
115 | 115 | //self::simplePrint($headers); die(""); |
116 | 116 | $ch = curl_init(); |
117 | - $url = $options['url'] . '?' . http_build_query(array_merge( |
|
118 | - $query, array( 'api_key' => self::getApiKey()) |
|
117 | + $url = $options['url'].'?'.http_build_query(array_merge( |
|
118 | + $query, array('api_key' => self::getApiKey()) |
|
119 | 119 | )); |
120 | 120 | //var_dump($body); echo "<br><br>"; |
121 | 121 | //$jfile=json_encode($body); echo "<br><br>".$jfile; die("STOPPPP"); |
122 | 122 | |
123 | 123 | //self::simplePrint($headers); die(""); |
124 | - $baseUrl=self::getBaseUrl(); |
|
124 | + $baseUrl = self::getBaseUrl(); |
|
125 | 125 | |
126 | - if (strpos($url,'move_route_destination')>0) $baseUrl='https://api.route4me.com'; |
|
126 | + if (strpos($url, 'move_route_destination')>0) $baseUrl = 'https://api.route4me.com'; |
|
127 | 127 | $curlOpts = arraY( |
128 | - CURLOPT_URL => $baseUrl. $url, |
|
128 | + CURLOPT_URL => $baseUrl.$url, |
|
129 | 129 | CURLOPT_RETURNTRANSFER => true, |
130 | 130 | CURLOPT_TIMEOUT => 60, |
131 | 131 | CURLOPT_FOLLOWLOCATION => true, |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | //echo "url=".$baseUrl.$url."<br>";die(""); |
138 | 138 | curl_setopt_array($ch, $curlOpts); |
139 | 139 | |
140 | - if ($file !=null) { |
|
140 | + if ($file!=null) { |
|
141 | 141 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
142 | - $fp=fopen($file,'r'); |
|
143 | - curl_setopt($ch, CURLOPT_INFILE , $fp); |
|
142 | + $fp = fopen($file, 'r'); |
|
143 | + curl_setopt($ch, CURLOPT_INFILE, $fp); |
|
144 | 144 | curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file)); |
145 | 145 | } |
146 | 146 | |
147 | - switch($method) { |
|
147 | + switch ($method) { |
|
148 | 148 | case 'DELETE': |
149 | 149 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
150 | 150 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | break; |
170 | 170 | case 'POST': |
171 | 171 | if (isset($query)) { |
172 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
172 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | //echo "<br><br>". json_encode($body); |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | |
184 | 184 | $result = curl_exec($ch); |
185 | 185 | //var_dump($result); die(""); |
186 | - $isxml=FALSE; |
|
187 | - $jxml=""; |
|
186 | + $isxml = FALSE; |
|
187 | + $jxml = ""; |
|
188 | 188 | if (strpos($result, '<?xml')>-1) |
189 | 189 | { |
190 | 190 | $xml = simplexml_load_string($result); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | curl_close($ch); |
197 | 197 | //echo "code -> $code <br>"; |
198 | 198 | |
199 | - if (200 == $code) { |
|
199 | + if (200==$code) { |
|
200 | 200 | if ($isxml) { |
201 | 201 | $json = $jxml; |
202 | 202 | } else $json = json_decode($result, true); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | } else { |
207 | 207 | return $json; |
208 | 208 | } |
209 | - } elseif (409 == $code) { |
|
209 | + } elseif (409==$code) { |
|
210 | 210 | throw new ApiError('Wrong API key'); |
211 | 211 | } else { |
212 | 212 | throw new ApiError('Something wrong'); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | curl_setopt_array($ch, $curlOpts); |
237 | 237 | |
238 | - switch($method) { |
|
238 | + switch ($method) { |
|
239 | 239 | case 'DELETE': |
240 | 240 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
241 | 241 | |
@@ -273,8 +273,8 @@ discard block |
||
273 | 273 | |
274 | 274 | $result = curl_exec($ch); |
275 | 275 | |
276 | - $isxml=FALSE; |
|
277 | - $jxml=""; |
|
276 | + $isxml = FALSE; |
|
277 | + $jxml = ""; |
|
278 | 278 | if (strpos($result, '<?xml')>-1) |
279 | 279 | { |
280 | 280 | $xml = simplexml_load_string($result); |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | } else $json = json_decode($result, true); |
291 | 291 | |
292 | 292 | |
293 | - if (200 == $code) { |
|
293 | + if (200==$code) { |
|
294 | 294 | return $json; |
295 | 295 | } elseif (isset($json['errors'])) { |
296 | 296 | throw new ApiError(implode(', ', $json['errors'])); |