@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function __destruct() |
136 | 136 | { |
137 | - if($this->curl != null) curl_close($this->curl); |
|
137 | + if ($this->curl != null) curl_close($this->curl); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | private function buildQuery(array $parameters) |
148 | 148 | { |
149 | 149 | // no parameters? |
150 | - if(empty($parameters)) return ''; |
|
150 | + if (empty($parameters)) return ''; |
|
151 | 151 | |
152 | 152 | // encode the keys |
153 | 153 | $keys = self::urlencode_rfc3986(array_keys($parameters)); |
@@ -162,14 +162,14 @@ discard block |
||
162 | 162 | uksort($parameters, 'strcmp'); |
163 | 163 | |
164 | 164 | // loop parameters |
165 | - foreach($parameters as $key => $value) |
|
165 | + foreach ($parameters as $key => $value) |
|
166 | 166 | { |
167 | 167 | // sort by value |
168 | - if(is_array($value)) $parameters[$key] = natsort($value); |
|
168 | + if (is_array($value)) $parameters[$key] = natsort($value); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | // process parameters |
172 | - foreach($parameters as $key => $value) $chunks[] = $key .'='. str_replace('%25', '%', $value); |
|
172 | + foreach ($parameters as $key => $value) $chunks[] = $key.'='.str_replace('%25', '%', $value); |
|
173 | 173 | |
174 | 174 | // return |
175 | 175 | return implode('&', $chunks); |
@@ -205,21 +205,21 @@ discard block |
||
205 | 205 | uksort($parameters, 'strcmp'); |
206 | 206 | |
207 | 207 | // loop parameters |
208 | - foreach($parameters as $key => $value) |
|
208 | + foreach ($parameters as $key => $value) |
|
209 | 209 | { |
210 | 210 | // sort by value |
211 | - if(is_array($value)) $parameters[$key] = natsort($value); |
|
211 | + if (is_array($value)) $parameters[$key] = natsort($value); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | // process queries |
215 | - foreach($parameters as $key => $value) |
|
215 | + foreach ($parameters as $key => $value) |
|
216 | 216 | { |
217 | - $chunks[] = self::urlencode_rfc3986($key) .'%3D'. self::urlencode_rfc3986($value); |
|
217 | + $chunks[] = self::urlencode_rfc3986($key).'%3D'.self::urlencode_rfc3986($value); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | // buils base |
221 | - $base = $method .'&'; |
|
222 | - $base .= urlencode($url) .'&'; |
|
221 | + $base = $method.'&'; |
|
222 | + $base .= urlencode($url).'&'; |
|
223 | 223 | $base .= implode('%26', $chunks); |
224 | 224 | |
225 | 225 | // return |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | $chunks = array(); |
247 | 247 | |
248 | 248 | // process queries |
249 | - foreach($parameters as $key => $value) $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) .'="'. self::urlencode_rfc3986($value) .'"'); |
|
249 | + foreach ($parameters as $key => $value) $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key).'="'.self::urlencode_rfc3986($value).'"'); |
|
250 | 250 | |
251 | 251 | // build return |
252 | - $return = 'Authorization: OAuth realm="' . $parts['scheme'] . '://' . $parts['host'] . $parts['path'] . '", '; |
|
252 | + $return = 'Authorization: OAuth realm="'.$parts['scheme'].'://'.$parts['host'].$parts['path'].'", '; |
|
253 | 253 | $return .= implode(',', $chunks); |
254 | 254 | |
255 | 255 | // prepend name and OAuth part |
@@ -272,22 +272,22 @@ discard block |
||
272 | 272 | |
273 | 273 | // append default parameters |
274 | 274 | $parameters['oauth_consumer_key'] = $this->getConsumerKey(); |
275 | - $parameters['oauth_nonce'] = md5(microtime() . rand()); |
|
275 | + $parameters['oauth_nonce'] = md5(microtime().rand()); |
|
276 | 276 | $parameters['oauth_timestamp'] = time(); |
277 | 277 | $parameters['oauth_signature_method'] = 'HMAC-SHA1'; |
278 | 278 | $parameters['oauth_version'] = '1.0'; |
279 | 279 | |
280 | 280 | // calculate the base string |
281 | - $base = $this->calculateBaseString(self::SECURE_API_URL .'/oauth/'. $method, 'POST', $parameters); |
|
281 | + $base = $this->calculateBaseString(self::SECURE_API_URL.'/oauth/'.$method, 'POST', $parameters); |
|
282 | 282 | |
283 | 283 | // add sign into the parameters |
284 | - $parameters['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret() .'&' . $this->getOAuthTokenSecret(), $base); |
|
284 | + $parameters['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret().'&'.$this->getOAuthTokenSecret(), $base); |
|
285 | 285 | |
286 | 286 | // calculate header |
287 | - $header = $this->calculateHeader($parameters, self::SECURE_API_URL .'/oauth/'. $method); |
|
287 | + $header = $this->calculateHeader($parameters, self::SECURE_API_URL.'/oauth/'.$method); |
|
288 | 288 | |
289 | 289 | // set options |
290 | - $options[CURLOPT_URL] = self::SECURE_API_URL .'/oauth/'. $method; |
|
290 | + $options[CURLOPT_URL] = self::SECURE_API_URL.'/oauth/'.$method; |
|
291 | 291 | $options[CURLOPT_PORT] = self::SECURE_API_PORT; |
292 | 292 | $options[CURLOPT_USERAGENT] = $this->getUserAgent(); |
293 | 293 | $options[CURLOPT_FOLLOWLOCATION] = true; |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | $options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters); |
301 | 301 | |
302 | 302 | // init |
303 | - if($this->curl == null) $this->curl = curl_init(); |
|
303 | + if ($this->curl == null) $this->curl = curl_init(); |
|
304 | 304 | |
305 | 305 | // set options |
306 | 306 | curl_setopt_array($this->curl, $options); |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | $errorMessage = curl_error($this->curl); |
315 | 315 | |
316 | 316 | // error? |
317 | - if($errorNumber != '') throw new TwitterException($errorMessage, $errorNumber); |
|
317 | + if ($errorNumber != '') throw new TwitterException($errorMessage, $errorNumber); |
|
318 | 318 | |
319 | 319 | // init var |
320 | 320 | $return = array(); |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | $expectJSON = (bool) $expectJSON; |
350 | 350 | |
351 | 351 | // validate method |
352 | - if(!in_array($method, $allowedMethods)) throw new TwitterException('Unknown method ('. $method .'). Allowed methods are: '. implode(', ', $allowedMethods)); |
|
352 | + if (!in_array($method, $allowedMethods)) throw new TwitterException('Unknown method ('.$method.'). Allowed methods are: '.implode(', ', $allowedMethods)); |
|
353 | 353 | |
354 | 354 | // append default parameters |
355 | 355 | $oauth['oauth_consumer_key'] = $this->getConsumerKey(); |
356 | - $oauth['oauth_nonce'] = md5(microtime() . rand()); |
|
356 | + $oauth['oauth_nonce'] = md5(microtime().rand()); |
|
357 | 357 | $oauth['oauth_timestamp'] = time(); |
358 | 358 | $oauth['oauth_token'] = $this->getOAuthToken(); |
359 | 359 | $oauth['oauth_signature_method'] = 'HMAC-SHA1'; |
@@ -361,22 +361,22 @@ discard block |
||
361 | 361 | |
362 | 362 | // set data |
363 | 363 | $data = $oauth; |
364 | - if(!empty($parameters)) $data = array_merge($data, $parameters); |
|
364 | + if (!empty($parameters)) $data = array_merge($data, $parameters); |
|
365 | 365 | |
366 | 366 | // calculate the base string |
367 | - $base = $this->calculateBaseString(self::API_URL .'/'. $url, $method, $data); |
|
367 | + $base = $this->calculateBaseString(self::API_URL.'/'.$url, $method, $data); |
|
368 | 368 | |
369 | 369 | // add sign into the parameters |
370 | - $oauth['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret() .'&' . $this->getOAuthTokenSecret(), $base); |
|
370 | + $oauth['oauth_signature'] = $this->hmacsha1($this->getConsumerSecret().'&'.$this->getOAuthTokenSecret(), $base); |
|
371 | 371 | |
372 | - $headers[] = $this->calculateHeader($oauth, self::API_URL .'/'. $url); |
|
372 | + $headers[] = $this->calculateHeader($oauth, self::API_URL.'/'.$url); |
|
373 | 373 | $headers[] = 'Expect:'; |
374 | 374 | |
375 | 375 | // based on the method, we should handle the parameters in a different way |
376 | - if($method == 'POST') |
|
376 | + if ($method == 'POST') |
|
377 | 377 | { |
378 | 378 | // file provided? |
379 | - if($filePath != null) |
|
379 | + if ($filePath != null) |
|
380 | 380 | { |
381 | 381 | // build a boundary |
382 | 382 | $boundary = md5(time()); |
@@ -386,19 +386,19 @@ discard block |
||
386 | 386 | |
387 | 387 | // set mimeType |
388 | 388 | $mimeType = 'application/octet-stream'; |
389 | - if($fileInfo['extension'] == 'jpg' || $fileInfo['extension'] == 'jpeg') $mimeType = 'image/jpeg'; |
|
390 | - elseif($fileInfo['extension'] == 'gif') $mimeType = 'image/gif'; |
|
391 | - elseif($fileInfo['extension'] == 'png') $mimeType = 'image/png'; |
|
389 | + if ($fileInfo['extension'] == 'jpg' || $fileInfo['extension'] == 'jpeg') $mimeType = 'image/jpeg'; |
|
390 | + elseif ($fileInfo['extension'] == 'gif') $mimeType = 'image/gif'; |
|
391 | + elseif ($fileInfo['extension'] == 'png') $mimeType = 'image/png'; |
|
392 | 392 | |
393 | 393 | // init var |
394 | - $content = '--'. $boundary ."\r\n"; |
|
394 | + $content = '--'.$boundary."\r\n"; |
|
395 | 395 | |
396 | 396 | // set file |
397 | - $content = 'Content-Disposition: form-data; name="image";filename="'. $fileInfo['basename'] .'"' ."\r\n" . 'Content-Type: '. $mimeType . "\r\n\r\n" . file_get_contents($filePath) ."\r\n--". $boundary ."\r\n"; |
|
397 | + $content = 'Content-Disposition: form-data; name="image";filename="'.$fileInfo['basename'].'"'."\r\n".'Content-Type: '.$mimeType."\r\n\r\n".file_get_contents($filePath)."\r\n--".$boundary."\r\n"; |
|
398 | 398 | |
399 | 399 | // build headers |
400 | - $headers[] = 'Content-Type: multipart/form-data; boundary=' . $boundary; |
|
401 | - $headers[] = 'Content-Length: '. strlen($content); |
|
400 | + $headers[] = 'Content-Type: multipart/form-data; boundary='.$boundary; |
|
401 | + $headers[] = 'Content-Length: '.strlen($content); |
|
402 | 402 | |
403 | 403 | // set content |
404 | 404 | $options[CURLOPT_POSTFIELDS] = $content; |
@@ -414,11 +414,11 @@ discard block |
||
414 | 414 | else |
415 | 415 | { |
416 | 416 | // add the parameters into the querystring |
417 | - if(!empty($parameters)) $url .= '?'. $this->buildQuery($parameters); |
|
417 | + if (!empty($parameters)) $url .= '?'.$this->buildQuery($parameters); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | // set options |
421 | - $options[CURLOPT_URL] = self::API_URL .'/'. $url; |
|
421 | + $options[CURLOPT_URL] = self::API_URL.'/'.$url; |
|
422 | 422 | $options[CURLOPT_PORT] = self::API_PORT; |
423 | 423 | $options[CURLOPT_USERAGENT] = $this->getUserAgent(); |
424 | 424 | $options[CURLOPT_FOLLOWLOCATION] = true; |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $options[CURLOPT_HTTPHEADER] = $headers; |
431 | 431 | |
432 | 432 | // init |
433 | - if($this->curl == null) $this->curl = curl_init(); |
|
433 | + if ($this->curl == null) $this->curl = curl_init(); |
|
434 | 434 | |
435 | 435 | // set options |
436 | 436 | curl_setopt_array($this->curl, $options); |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | $errorMessage = curl_error($this->curl); |
445 | 445 | |
446 | 446 | // we don't expext JSON, return the response |
447 | - if(!$expectJSON) return $response; |
|
447 | + if (!$expectJSON) return $response; |
|
448 | 448 | |
449 | 449 | // replace ids with their string values, added because of some PHP-version can't handle these large values |
450 | 450 | $response = preg_replace('/id":(\d+)/', 'id":"\1"', $response); |
@@ -453,10 +453,10 @@ discard block |
||
453 | 453 | $json = @json_decode($response, true); |
454 | 454 | |
455 | 455 | // validate JSON |
456 | - if($json === null) |
|
456 | + if ($json === null) |
|
457 | 457 | { |
458 | 458 | // should we provide debug information |
459 | - if(self::DEBUG) |
|
459 | + if (self::DEBUG) |
|
460 | 460 | { |
461 | 461 | // make it output proper |
462 | 462 | echo '<pre>'; |
@@ -480,10 +480,10 @@ discard block |
||
480 | 480 | |
481 | 481 | |
482 | 482 | // any errors |
483 | - if(isset($json['errors'])) |
|
483 | + if (isset($json['errors'])) |
|
484 | 484 | { |
485 | 485 | // should we provide debug information |
486 | - if(self::DEBUG) |
|
486 | + if (self::DEBUG) |
|
487 | 487 | { |
488 | 488 | // make it output proper |
489 | 489 | echo '<pre>'; |
@@ -502,16 +502,16 @@ discard block |
||
502 | 502 | } |
503 | 503 | |
504 | 504 | // throw exception |
505 | - if(isset($json['errors'][0]['message'])) throw new TwitterException($json['errors'][0]['message']); |
|
505 | + if (isset($json['errors'][0]['message'])) throw new TwitterException($json['errors'][0]['message']); |
|
506 | 506 | else throw new TwitterException('Invalid response.'); |
507 | 507 | } |
508 | 508 | |
509 | 509 | |
510 | 510 | // any error |
511 | - if(isset($json['error'])) |
|
511 | + if (isset($json['error'])) |
|
512 | 512 | { |
513 | 513 | // should we provide debug information |
514 | - if(self::DEBUG) |
|
514 | + if (self::DEBUG) |
|
515 | 515 | { |
516 | 516 | // make it output proper |
517 | 517 | echo '<pre>'; |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | */ |
599 | 599 | public function getUserAgent() |
600 | 600 | { |
601 | - return (string) 'PHP Twitter/'. self::VERSION .' '. $this->userAgent; |
|
601 | + return (string) 'PHP Twitter/'.self::VERSION.' '.$this->userAgent; |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | */ |
697 | 697 | private static function urlencode_rfc3986($value) |
698 | 698 | { |
699 | - if(is_array($value)) return array_map(array('Twitter', 'urlencode_rfc3986'), $value); |
|
699 | + if (is_array($value)) return array_map(array('Twitter', 'urlencode_rfc3986'), $value); |
|
700 | 700 | else |
701 | 701 | { |
702 | 702 | $search = array('+', ' ', '%7E', '%'); |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | |
723 | 723 | // build parameters |
724 | 724 | $parameters = array(); |
725 | - if($skipUser) $parameters['skip_user'] = 'true'; |
|
725 | + if ($skipUser) $parameters['skip_user'] = 'true'; |
|
726 | 726 | |
727 | 727 | // make the call |
728 | 728 | return (array) $this->doCall('statuses/public_timeline.json', $parameters); |
@@ -746,11 +746,11 @@ discard block |
||
746 | 746 | |
747 | 747 | // build parameters |
748 | 748 | $parameters = array(); |
749 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
750 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
751 | - if($count != null) $parameters['count'] = (int) $count; |
|
752 | - if($page != null) $parameters['page'] = (int) $page; |
|
753 | - if($skipUser) $parameters['skip_user'] = 'true'; |
|
749 | + if ($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
750 | + if ($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
751 | + if ($count != null) $parameters['count'] = (int) $count; |
|
752 | + if ($page != null) $parameters['page'] = (int) $page; |
|
753 | + if ($skipUser) $parameters['skip_user'] = 'true'; |
|
754 | 754 | |
755 | 755 | // make the call |
756 | 756 | return (array) $this->doCall('statuses/home_timeline.json', $parameters, true); |
@@ -778,11 +778,11 @@ discard block |
||
778 | 778 | |
779 | 779 | // build parameters |
780 | 780 | $parameters = array(); |
781 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
782 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
783 | - if($count != null) $parameters['count'] = (int) $count; |
|
784 | - if($page != null) $parameters['page'] = (int) $page; |
|
785 | - if($skipUser) $parameters['skip_user'] = 'true'; |
|
781 | + if ($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
782 | + if ($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
783 | + if ($count != null) $parameters['count'] = (int) $count; |
|
784 | + if ($page != null) $parameters['page'] = (int) $page; |
|
785 | + if ($skipUser) $parameters['skip_user'] = 'true'; |
|
786 | 786 | |
787 | 787 | // make the call |
788 | 788 | return (array) $this->doCall('statuses/friends_timeline.json', $parameters, true); |
@@ -813,14 +813,14 @@ discard block |
||
813 | 813 | |
814 | 814 | // build parameters |
815 | 815 | $parameters = array(); |
816 | - if($id != null) $parameters['id'] = (string) $id; |
|
817 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
818 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
819 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
820 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
821 | - if($count != null) $parameters['count'] = (int) $count; |
|
822 | - if($page != null) $parameters['page'] = (int) $page; |
|
823 | - if($skipUser) $parameters['skip_user'] = 'true'; |
|
816 | + if ($id != null) $parameters['id'] = (string) $id; |
|
817 | + if ($userId != null) $parameters['user_id'] = (string) $userId; |
|
818 | + if ($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
819 | + if ($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
820 | + if ($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
821 | + if ($count != null) $parameters['count'] = (int) $count; |
|
822 | + if ($page != null) $parameters['page'] = (int) $page; |
|
823 | + if ($skipUser) $parameters['skip_user'] = 'true'; |
|
824 | 824 | |
825 | 825 | // make the call |
826 | 826 | return (array) $this->doCall('statuses/user_timeline.json', $parameters, true); |
@@ -839,14 +839,14 @@ discard block |
||
839 | 839 | public function statusesMentions($sinceId = null, $maxId = null, $count = null, $page = null) |
840 | 840 | { |
841 | 841 | // validate |
842 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
842 | + if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
843 | 843 | |
844 | 844 | // build parameters |
845 | 845 | $parameters = array(); |
846 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
847 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
848 | - if($count != null) $parameters['count'] = (int) $count; |
|
849 | - if($page != null) $parameters['page'] = (int) $page; |
|
846 | + if ($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
847 | + if ($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
848 | + if ($count != null) $parameters['count'] = (int) $count; |
|
849 | + if ($page != null) $parameters['page'] = (int) $page; |
|
850 | 850 | |
851 | 851 | // make the call |
852 | 852 | return (array) $this->doCall('statuses/mentions.json', $parameters); |
@@ -865,14 +865,14 @@ discard block |
||
865 | 865 | public function statusesRetweetedByMe($sinceId = null, $maxId = null, $count = null, $page = null) |
866 | 866 | { |
867 | 867 | // validate |
868 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
868 | + if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
869 | 869 | |
870 | 870 | // build parameters |
871 | 871 | $parameters = array(); |
872 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
873 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
874 | - if($count != null) $parameters['count'] = (int) $count; |
|
875 | - if($page != null) $parameters['page'] = (int) $page; |
|
872 | + if ($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
873 | + if ($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
874 | + if ($count != null) $parameters['count'] = (int) $count; |
|
875 | + if ($page != null) $parameters['page'] = (int) $page; |
|
876 | 876 | |
877 | 877 | // make the call |
878 | 878 | return (array) $this->doCall('statuses/retweeted_by_me.json', $parameters); |
@@ -891,14 +891,14 @@ discard block |
||
891 | 891 | public function statusesRetweetedToMe($sinceId = null, $maxId = null, $count = null, $page = null) |
892 | 892 | { |
893 | 893 | // validate |
894 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
894 | + if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
895 | 895 | |
896 | 896 | // build parameters |
897 | 897 | $parameters = array(); |
898 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
899 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
900 | - if($count != null) $parameters['count'] = (int) $count; |
|
901 | - if($page != null) $parameters['page'] = (int) $page; |
|
898 | + if ($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
899 | + if ($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
900 | + if ($count != null) $parameters['count'] = (int) $count; |
|
901 | + if ($page != null) $parameters['page'] = (int) $page; |
|
902 | 902 | |
903 | 903 | // make the call |
904 | 904 | return (array) $this->doCall('statuses/retweeted_by_me.json', $parameters); |
@@ -918,14 +918,14 @@ discard block |
||
918 | 918 | public function statusesReweetsOfMe($sinceId = null, $maxId = null, $count = null, $page = null) |
919 | 919 | { |
920 | 920 | // validate |
921 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
921 | + if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
922 | 922 | |
923 | 923 | // build parameters |
924 | 924 | $parameters = array(); |
925 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
926 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
927 | - if($count != null) $parameters['count'] = (int) $count; |
|
928 | - if($page != null) $parameters['page'] = (int) $page; |
|
925 | + if ($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
926 | + if ($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
927 | + if ($count != null) $parameters['count'] = (int) $count; |
|
928 | + if ($page != null) $parameters['page'] = (int) $page; |
|
929 | 929 | |
930 | 930 | // make the call |
931 | 931 | return (array) $this->doCall('statuses/retweets_of_me.json', $parameters); |
@@ -963,11 +963,11 @@ discard block |
||
963 | 963 | { |
964 | 964 | // build parameters |
965 | 965 | $parameters['status'] = (string) $status; |
966 | - if($inReplyToStatusId != null) $parameters['in_reply_to_status_id'] = (string) $inReplyToStatusId; |
|
967 | - if($lat != null) $parameters['lat'] = (float) $lat; |
|
968 | - if($long != null) $parameters['long'] = (float) $long; |
|
969 | - if($placeId != null) $parameters['place_id'] = (string) $placeId; |
|
970 | - if($displayCoordinates) $parameters['display_coordinates'] = 'true'; |
|
966 | + if ($inReplyToStatusId != null) $parameters['in_reply_to_status_id'] = (string) $inReplyToStatusId; |
|
967 | + if ($lat != null) $parameters['lat'] = (float) $lat; |
|
968 | + if ($long != null) $parameters['long'] = (float) $long; |
|
969 | + if ($placeId != null) $parameters['place_id'] = (string) $placeId; |
|
970 | + if ($displayCoordinates) $parameters['display_coordinates'] = 'true'; |
|
971 | 971 | |
972 | 972 | // make the call |
973 | 973 | return (array) $this->doCall('statuses/update.json', $parameters, true, 'POST'); |
@@ -1000,7 +1000,7 @@ discard block |
||
1000 | 1000 | public function statusesRetweet($id) |
1001 | 1001 | { |
1002 | 1002 | // make the call |
1003 | - return (array) $this->doCall('statuses/retweet/'. $id .'.json', null, true, 'POST'); |
|
1003 | + return (array) $this->doCall('statuses/retweet/'.$id.'.json', null, true, 'POST'); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | |
@@ -1015,14 +1015,14 @@ discard block |
||
1015 | 1015 | public function statusesRetweets($id, $count = null) |
1016 | 1016 | { |
1017 | 1017 | // validate |
1018 | - if($count != null && $count > 100) throw new TwitterException('Count may not be greater than 100.'); |
|
1018 | + if ($count != null && $count > 100) throw new TwitterException('Count may not be greater than 100.'); |
|
1019 | 1019 | |
1020 | 1020 | // build parameters |
1021 | 1021 | $parameters = null; |
1022 | - if($count != null) $parameters['count'] = (int) $count; |
|
1022 | + if ($count != null) $parameters['count'] = (int) $count; |
|
1023 | 1023 | |
1024 | 1024 | // make the call |
1025 | - return (array) $this->doCall('statuses/retweets/'. $id .'.json', $parameters); |
|
1025 | + return (array) $this->doCall('statuses/retweets/'.$id.'.json', $parameters); |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | |
@@ -1037,15 +1037,15 @@ discard block |
||
1037 | 1037 | public function statusesIdRetweetedBy($id, $count = null, $page = null) |
1038 | 1038 | { |
1039 | 1039 | // validate |
1040 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1040 | + if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1041 | 1041 | |
1042 | 1042 | // build parameters |
1043 | 1043 | $parameters = null; |
1044 | - if($count != null) $parameters['count'] = (int) $count; |
|
1045 | - if($page != null) $parameters['page'] = (int) $page; |
|
1044 | + if ($count != null) $parameters['count'] = (int) $count; |
|
1045 | + if ($page != null) $parameters['page'] = (int) $page; |
|
1046 | 1046 | |
1047 | 1047 | // make the call |
1048 | - return (array) $this->doCall('statuses/'. (string) $id .'/retweeted_by.json', $parameters, true); |
|
1048 | + return (array) $this->doCall('statuses/'.(string) $id.'/retweeted_by.json', $parameters, true); |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | |
@@ -1060,15 +1060,15 @@ discard block |
||
1060 | 1060 | public function statusesIdRetweetedByIds($id, $count = null, $page = null) |
1061 | 1061 | { |
1062 | 1062 | // validate |
1063 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1063 | + if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1064 | 1064 | |
1065 | 1065 | // build parameters |
1066 | 1066 | $parameters = null; |
1067 | - if($count != null) $parameters['count'] = (int) $count; |
|
1068 | - if($page != null) $parameters['page'] = (int) $page; |
|
1067 | + if ($count != null) $parameters['count'] = (int) $count; |
|
1068 | + if ($page != null) $parameters['page'] = (int) $page; |
|
1069 | 1069 | |
1070 | 1070 | // make the call |
1071 | - return (array) $this->doCall('statuses/'. (string) $id .'/retweeted_by/ids.json', $parameters, true); |
|
1071 | + return (array) $this->doCall('statuses/'.(string) $id.'/retweeted_by/ids.json', $parameters, true); |
|
1072 | 1072 | } |
1073 | 1073 | |
1074 | 1074 | |
@@ -1085,12 +1085,12 @@ discard block |
||
1085 | 1085 | public function usersShow($id = null, $userId = null, $screenName = null) |
1086 | 1086 | { |
1087 | 1087 | // validate |
1088 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1088 | + if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1089 | 1089 | |
1090 | 1090 | // build parameters |
1091 | - if($id != null) $parameters['id'] = (string) $id; |
|
1092 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1093 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1091 | + if ($id != null) $parameters['id'] = (string) $id; |
|
1092 | + if ($userId != null) $parameters['user_id'] = (string) $userId; |
|
1093 | + if ($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1094 | 1094 | |
1095 | 1095 | // make the call |
1096 | 1096 | return (array) $this->doCall('users/show.json', $parameters); |
@@ -1112,11 +1112,11 @@ discard block |
||
1112 | 1112 | $screenNames = (array) $screenNames; |
1113 | 1113 | |
1114 | 1114 | // validate |
1115 | - if(empty($userIds) && empty($screenNames)) throw new TwitterException('Specify an userId or a screenName.'); |
|
1115 | + if (empty($userIds) && empty($screenNames)) throw new TwitterException('Specify an userId or a screenName.'); |
|
1116 | 1116 | |
1117 | 1117 | // build parameters |
1118 | - if(!empty($userIds)) $parameters['user_id'] = implode(',', $userIds); |
|
1119 | - if(!empty($screenNames)) $parameters['screen_name'] = implode(',', $screenNames); |
|
1118 | + if (!empty($userIds)) $parameters['user_id'] = implode(',', $userIds); |
|
1119 | + if (!empty($screenNames)) $parameters['screen_name'] = implode(',', $screenNames); |
|
1120 | 1120 | |
1121 | 1121 | // make the call |
1122 | 1122 | return (array) $this->doCall('users/lookup.json', $parameters, true); |
@@ -1137,8 +1137,8 @@ discard block |
||
1137 | 1137 | { |
1138 | 1138 | // build parameters |
1139 | 1139 | $parameters['q'] = (string) $q; |
1140 | - if($perPage != null) $parameters['per_page'] = (int) $perPage; |
|
1141 | - if($page != null) $parameters['page'] = (int) $page; |
|
1140 | + if ($perPage != null) $parameters['per_page'] = (int) $perPage; |
|
1141 | + if ($page != null) $parameters['page'] = (int) $page; |
|
1142 | 1142 | |
1143 | 1143 | // make the call |
1144 | 1144 | return (array) $this->doCall('users/search.json', $parameters, true); |
@@ -1166,7 +1166,7 @@ discard block |
||
1166 | 1166 | */ |
1167 | 1167 | public function usersSuggestionsSlug($slug) |
1168 | 1168 | { |
1169 | - return (array) $this->doCall('users/suggestions/'. (string) $slug .'.json'); |
|
1169 | + return (array) $this->doCall('users/suggestions/'.(string) $slug.'.json'); |
|
1170 | 1170 | } |
1171 | 1171 | |
1172 | 1172 | |
@@ -1188,10 +1188,10 @@ discard block |
||
1188 | 1188 | { |
1189 | 1189 | // build parameters |
1190 | 1190 | $parameters = array(); |
1191 | - if($id != null) $parameters['id'] = (string) $id; |
|
1192 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1193 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1194 | - if($cursor != null) $parameters['cursor'] = (int) $cursor; |
|
1191 | + if ($id != null) $parameters['id'] = (string) $id; |
|
1192 | + if ($userId != null) $parameters['user_id'] = (string) $userId; |
|
1193 | + if ($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1194 | + if ($cursor != null) $parameters['cursor'] = (int) $cursor; |
|
1195 | 1195 | |
1196 | 1196 | // make the call |
1197 | 1197 | return (array) $this->doCall('statuses/friends.json', $parameters); |
@@ -1212,10 +1212,10 @@ discard block |
||
1212 | 1212 | { |
1213 | 1213 | // build parameters |
1214 | 1214 | $parameters = array(); |
1215 | - if($id != null) $parameters['id'] = (string) $id; |
|
1216 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1217 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1218 | - if($cursor != null) $parameters['cursor'] = (int) $cursor; |
|
1215 | + if ($id != null) $parameters['id'] = (string) $id; |
|
1216 | + if ($userId != null) $parameters['user_id'] = (string) $userId; |
|
1217 | + if ($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1218 | + if ($cursor != null) $parameters['cursor'] = (int) $cursor; |
|
1219 | 1219 | |
1220 | 1220 | // make the call |
1221 | 1221 | return (array) $this->doCall('statuses/followers.json', $parameters); |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | { |
1247 | 1247 | // build parameters |
1248 | 1248 | $parameters = array(); |
1249 | - if($exclude != null) $parameters['exclude'] = (string) $exclude; |
|
1249 | + if ($exclude != null) $parameters['exclude'] = (string) $exclude; |
|
1250 | 1250 | |
1251 | 1251 | // make the call |
1252 | 1252 | return (array) $this->doCall('trends/current.json', $parameters); |
@@ -1264,8 +1264,8 @@ discard block |
||
1264 | 1264 | { |
1265 | 1265 | // build parameters |
1266 | 1266 | $parameters = array(); |
1267 | - if($exclude != null) $parameters['exclude'] = (string) $exclude; |
|
1268 | - if($date != null) $parameters['date'] = (string) $date; |
|
1267 | + if ($exclude != null) $parameters['exclude'] = (string) $exclude; |
|
1268 | + if ($date != null) $parameters['date'] = (string) $date; |
|
1269 | 1269 | |
1270 | 1270 | // make the call |
1271 | 1271 | return (array) $this->doCall('trends/daily.json', $parameters); |
@@ -1283,8 +1283,8 @@ discard block |
||
1283 | 1283 | { |
1284 | 1284 | // build parameters |
1285 | 1285 | $parameters = array(); |
1286 | - if($exclude != null) $parameters['exclude'] = (string) $exclude; |
|
1287 | - if($date != null) $parameters['date'] = (string) $date; |
|
1286 | + if ($exclude != null) $parameters['exclude'] = (string) $exclude; |
|
1287 | + if ($date != null) $parameters['date'] = (string) $date; |
|
1288 | 1288 | |
1289 | 1289 | // make the call |
1290 | 1290 | return (array) $this->doCall('trends/weekly.json', $parameters); |
@@ -1307,15 +1307,15 @@ discard block |
||
1307 | 1307 | $allowedModes = array('public', 'private'); |
1308 | 1308 | |
1309 | 1309 | // validate |
1310 | - if($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: '. implode($allowedModes) .'.'); |
|
1310 | + if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: '.implode($allowedModes).'.'); |
|
1311 | 1311 | |
1312 | 1312 | // build parameters |
1313 | 1313 | $parameters['name'] = (string) $name; |
1314 | - if($mode != null) $parameters['mode'] = (string) $mode; |
|
1315 | - if($description != null) $parameters['description'] = (string) $description; |
|
1314 | + if ($mode != null) $parameters['mode'] = (string) $mode; |
|
1315 | + if ($description != null) $parameters['description'] = (string) $description; |
|
1316 | 1316 | |
1317 | 1317 | // make the call |
1318 | - return (array) $this->doCall((string) $user .'/lists.json', $parameters, true, 'POST'); |
|
1318 | + return (array) $this->doCall((string) $user.'/lists.json', $parameters, true, 'POST'); |
|
1319 | 1319 | } |
1320 | 1320 | |
1321 | 1321 | |
@@ -1329,10 +1329,10 @@ discard block |
||
1329 | 1329 | public function userLists($user, $cursor = null) |
1330 | 1330 | { |
1331 | 1331 | $parameters = null; |
1332 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1332 | + if ($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1333 | 1333 | |
1334 | 1334 | // make the call |
1335 | - return (array) $this->doCall((string) $user .'/lists.json', $parameters, true); |
|
1335 | + return (array) $this->doCall((string) $user.'/lists.json', $parameters, true); |
|
1336 | 1336 | } |
1337 | 1337 | |
1338 | 1338 | |
@@ -1346,7 +1346,7 @@ discard block |
||
1346 | 1346 | public function userListsId($user, $id) |
1347 | 1347 | { |
1348 | 1348 | // make the call |
1349 | - return (array) $this->doCall((string) $user .'/lists/'. (string) $id .'.json', null, true); |
|
1349 | + return (array) $this->doCall((string) $user.'/lists/'.(string) $id.'.json', null, true); |
|
1350 | 1350 | } |
1351 | 1351 | |
1352 | 1352 | |
@@ -1366,15 +1366,15 @@ discard block |
||
1366 | 1366 | $allowedModes = array('public', 'private'); |
1367 | 1367 | |
1368 | 1368 | // validate |
1369 | - if($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: '. implode($allowedModes) .'.'); |
|
1369 | + if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: '.implode($allowedModes).'.'); |
|
1370 | 1370 | |
1371 | 1371 | // build parameters |
1372 | - if($name != null) $parameters['name'] = (string) $name; |
|
1373 | - if($mode != null) $parameters['mode'] = (string) $mode; |
|
1374 | - if($description != null) $parameters['description'] = (string) $description; |
|
1372 | + if ($name != null) $parameters['name'] = (string) $name; |
|
1373 | + if ($mode != null) $parameters['mode'] = (string) $mode; |
|
1374 | + if ($description != null) $parameters['description'] = (string) $description; |
|
1375 | 1375 | |
1376 | 1376 | // make the call |
1377 | - return (array) $this->doCall((string) $user .'/lists/'. (string) $id .'.json', $parameters, true, 'POST'); |
|
1377 | + return (array) $this->doCall((string) $user.'/lists/'.(string) $id.'.json', $parameters, true, 'POST'); |
|
1378 | 1378 | } |
1379 | 1379 | |
1380 | 1380 | |
@@ -1392,17 +1392,17 @@ discard block |
||
1392 | 1392 | public function userListsIdStatuses($user, $id, $sinceId = null, $maxId = null, $count = null, $page = null) |
1393 | 1393 | { |
1394 | 1394 | // validate |
1395 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1395 | + if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1396 | 1396 | |
1397 | 1397 | // build parameters |
1398 | 1398 | $parameters = array(); |
1399 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
1400 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
1401 | - if($count != null) $parameters['per_page'] = (int) $count; |
|
1402 | - if($page != null) $parameters['page'] = (int) $page; |
|
1399 | + if ($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
1400 | + if ($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
1401 | + if ($count != null) $parameters['per_page'] = (int) $count; |
|
1402 | + if ($page != null) $parameters['page'] = (int) $page; |
|
1403 | 1403 | |
1404 | 1404 | // make the call |
1405 | - return (array) $this->doCall((string) $user .'/lists/'. (string) $id .'/statuses.json', $parameters); |
|
1405 | + return (array) $this->doCall((string) $user.'/lists/'.(string) $id.'/statuses.json', $parameters); |
|
1406 | 1406 | } |
1407 | 1407 | |
1408 | 1408 | |
@@ -1416,10 +1416,10 @@ discard block |
||
1416 | 1416 | public function userListsMemberships($user, $cursor = null) |
1417 | 1417 | { |
1418 | 1418 | $parameters = null; |
1419 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1419 | + if ($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1420 | 1420 | |
1421 | 1421 | // make the call |
1422 | - return (array) $this->doCall((string) $user .'/lists/memberships.json', $parameters, true); |
|
1422 | + return (array) $this->doCall((string) $user.'/lists/memberships.json', $parameters, true); |
|
1423 | 1423 | } |
1424 | 1424 | |
1425 | 1425 | |
@@ -1433,10 +1433,10 @@ discard block |
||
1433 | 1433 | public function userListsSubscriptions($user, $cursor = null) |
1434 | 1434 | { |
1435 | 1435 | $parameters = null; |
1436 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1436 | + if ($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1437 | 1437 | |
1438 | 1438 | // make the call |
1439 | - return (array) $this->doCall((string) $user .'/lists/subscriptions.json', $parameters, true); |
|
1439 | + return (array) $this->doCall((string) $user.'/lists/subscriptions.json', $parameters, true); |
|
1440 | 1440 | } |
1441 | 1441 | |
1442 | 1442 | |
@@ -1452,10 +1452,10 @@ discard block |
||
1452 | 1452 | public function userListMembers($user, $id, $cursor = null) |
1453 | 1453 | { |
1454 | 1454 | $parameters = null; |
1455 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1455 | + if ($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1456 | 1456 | |
1457 | 1457 | // make the call |
1458 | - return (array) $this->doCall((string) $user .'/'. (string) $id .'/members.json', $parameters, true); |
|
1458 | + return (array) $this->doCall((string) $user.'/'.(string) $id.'/members.json', $parameters, true); |
|
1459 | 1459 | } |
1460 | 1460 | |
1461 | 1461 | |
@@ -1473,7 +1473,7 @@ discard block |
||
1473 | 1473 | $parameters['id'] = (string) $userId; |
1474 | 1474 | |
1475 | 1475 | // make the call |
1476 | - return (array) $this->doCall((string) $user .'/'. (string) $id .'/members.json', $parameters, true, 'POST'); |
|
1476 | + return (array) $this->doCall((string) $user.'/'.(string) $id.'/members.json', $parameters, true, 'POST'); |
|
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 | |
@@ -1492,7 +1492,7 @@ discard block |
||
1492 | 1492 | $parameters['_method'] = 'DELETE'; |
1493 | 1493 | |
1494 | 1494 | // make the call |
1495 | - return (array) $this->doCall((string) $user .'/'. (string) $id .'/members.json', $parameters, true, 'POST'); |
|
1495 | + return (array) $this->doCall((string) $user.'/'.(string) $id.'/members.json', $parameters, true, 'POST'); |
|
1496 | 1496 | } |
1497 | 1497 | |
1498 | 1498 | |
@@ -1509,13 +1509,13 @@ discard block |
||
1509 | 1509 | try |
1510 | 1510 | { |
1511 | 1511 | // make the call |
1512 | - return (array) $this->doCall((string) $user .'/'. (string) $id .'/members/'. (string) $userId .'.json', null, true); |
|
1512 | + return (array) $this->doCall((string) $user.'/'.(string) $id.'/members/'.(string) $userId.'.json', null, true); |
|
1513 | 1513 | } |
1514 | 1514 | |
1515 | 1515 | // catch exceptions |
1516 | - catch(TwitterException $e) |
|
1516 | + catch (TwitterException $e) |
|
1517 | 1517 | { |
1518 | - if($e->getMessage() == 'The specified user is not a member of this list') return false; |
|
1518 | + if ($e->getMessage() == 'The specified user is not a member of this list') return false; |
|
1519 | 1519 | else throw $e; |
1520 | 1520 | } |
1521 | 1521 | } |
@@ -1533,10 +1533,10 @@ discard block |
||
1533 | 1533 | public function userListSubscribers($user, $id, $cursor = null) |
1534 | 1534 | { |
1535 | 1535 | $parameters = null; |
1536 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1536 | + if ($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1537 | 1537 | |
1538 | 1538 | // make the call |
1539 | - return (array) $this->doCall((string) $user .'/'. (string) $id .'/subscribers.json', $parameters, true); |
|
1539 | + return (array) $this->doCall((string) $user.'/'.(string) $id.'/subscribers.json', $parameters, true); |
|
1540 | 1540 | } |
1541 | 1541 | |
1542 | 1542 | |
@@ -1550,7 +1550,7 @@ discard block |
||
1550 | 1550 | public function userListSubscribersCreate($user, $id) |
1551 | 1551 | { |
1552 | 1552 | // make the call |
1553 | - return (array) $this->doCall((string) $user .'/'. (string) $id .'/subscribers.json', null, true, 'POST'); |
|
1553 | + return (array) $this->doCall((string) $user.'/'.(string) $id.'/subscribers.json', null, true, 'POST'); |
|
1554 | 1554 | } |
1555 | 1555 | |
1556 | 1556 | |
@@ -1567,7 +1567,7 @@ discard block |
||
1567 | 1567 | $parameters['_method'] = 'DELETE'; |
1568 | 1568 | |
1569 | 1569 | // make the call |
1570 | - return (array) $this->doCall((string) $user .'/'. (string) $id .'/subscribers.json', $parameters, true, 'POST'); |
|
1570 | + return (array) $this->doCall((string) $user.'/'.(string) $id.'/subscribers.json', $parameters, true, 'POST'); |
|
1571 | 1571 | } |
1572 | 1572 | |
1573 | 1573 | |
@@ -1584,13 +1584,13 @@ discard block |
||
1584 | 1584 | try |
1585 | 1585 | { |
1586 | 1586 | // make the call |
1587 | - return (array) $this->doCall((string) $user .'/'. (string) $id .'/subscribers/'. (string) $userId .'.json', null, true); |
|
1587 | + return (array) $this->doCall((string) $user.'/'.(string) $id.'/subscribers/'.(string) $userId.'.json', null, true); |
|
1588 | 1588 | } |
1589 | 1589 | |
1590 | 1590 | // catch exceptions |
1591 | - catch(TwitterException $e) |
|
1591 | + catch (TwitterException $e) |
|
1592 | 1592 | { |
1593 | - if($e->getMessage() == 'The specified user is not a subscriber of this list') return false; |
|
1593 | + if ($e->getMessage() == 'The specified user is not a subscriber of this list') return false; |
|
1594 | 1594 | else throw $e; |
1595 | 1595 | } |
1596 | 1596 | |
@@ -1610,14 +1610,14 @@ discard block |
||
1610 | 1610 | public function directMessages($sinceId = null, $maxId = null, $count = null, $page = null) |
1611 | 1611 | { |
1612 | 1612 | // validate |
1613 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1613 | + if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1614 | 1614 | |
1615 | 1615 | // build parameters |
1616 | 1616 | $parameters = array(); |
1617 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
1618 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
1619 | - if($count != null) $parameters['count'] = (int) $count; |
|
1620 | - if($page != null) $parameters['page'] = (int) $page; |
|
1617 | + if ($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
1618 | + if ($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
1619 | + if ($count != null) $parameters['count'] = (int) $count; |
|
1620 | + if ($page != null) $parameters['page'] = (int) $page; |
|
1621 | 1621 | |
1622 | 1622 | // make the call |
1623 | 1623 | return (array) $this->doCall('direct_messages.json', $parameters, true); |
@@ -1636,14 +1636,14 @@ discard block |
||
1636 | 1636 | public function directMessagesSent($sinceId = null, $maxId = null, $count = null, $page = null) |
1637 | 1637 | { |
1638 | 1638 | // validate |
1639 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1639 | + if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1640 | 1640 | |
1641 | 1641 | // build parameters |
1642 | 1642 | $parameters = array(); |
1643 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
1644 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
1645 | - if($count != null) $parameters['count'] = (int) $count; |
|
1646 | - if($page != null) $parameters['page'] = (int) $page; |
|
1643 | + if ($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
1644 | + if ($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
1645 | + if ($count != null) $parameters['count'] = (int) $count; |
|
1646 | + if ($page != null) $parameters['page'] = (int) $page; |
|
1647 | 1647 | |
1648 | 1648 | // make the call |
1649 | 1649 | return (array) $this->doCall('direct_messages/sent.json', $parameters, true); |
@@ -1663,13 +1663,13 @@ discard block |
||
1663 | 1663 | public function directMessagesNew($text, $id = null, $userId = null, $screenName = null) |
1664 | 1664 | { |
1665 | 1665 | // validate |
1666 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1666 | + if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1667 | 1667 | |
1668 | 1668 | // build parameters |
1669 | 1669 | $parameters['text'] = (string) $text; |
1670 | - if($id != null) $parameters['user'] = (string) $id; |
|
1671 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1672 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1670 | + if ($id != null) $parameters['user'] = (string) $id; |
|
1671 | + if ($userId != null) $parameters['user_id'] = (string) $userId; |
|
1672 | + if ($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1673 | 1673 | |
1674 | 1674 | // make the call |
1675 | 1675 | return (array) $this->doCall('direct_messages/new.json', $parameters, true, 'POST'); |
@@ -1707,12 +1707,12 @@ discard block |
||
1707 | 1707 | public function friendshipsCreate($id = null, $userId = null, $screenName = null, $follow = false) |
1708 | 1708 | { |
1709 | 1709 | // validate |
1710 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1710 | + if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1711 | 1711 | |
1712 | 1712 | // build parameters |
1713 | - if($id != null) $parameters['id'] = (string) $id; |
|
1714 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1715 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1713 | + if ($id != null) $parameters['id'] = (string) $id; |
|
1714 | + if ($userId != null) $parameters['user_id'] = (string) $userId; |
|
1715 | + if ($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1716 | 1716 | $parameters['follow'] = ($follow) ? 'true' : 'false'; |
1717 | 1717 | |
1718 | 1718 | // make the call |
@@ -1732,12 +1732,12 @@ discard block |
||
1732 | 1732 | public function friendshipsDestroy($id = null, $userId = null, $screenName = null) |
1733 | 1733 | { |
1734 | 1734 | // validate |
1735 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1735 | + if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1736 | 1736 | |
1737 | 1737 | // build parameters |
1738 | - if($id != null) $parameters['id'] = (string) $id; |
|
1739 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1740 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1738 | + if ($id != null) $parameters['id'] = (string) $id; |
|
1739 | + if ($userId != null) $parameters['user_id'] = (string) $userId; |
|
1740 | + if ($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1741 | 1741 | |
1742 | 1742 | // make the call |
1743 | 1743 | return (array) $this->doCall('friendships/destroy.json', $parameters, true, 'POST'); |
@@ -1774,14 +1774,14 @@ discard block |
||
1774 | 1774 | public function friendshipsShow($sourceId = null, $sourceScreenName = null, $targetId = null, $targetScreenName = null) |
1775 | 1775 | { |
1776 | 1776 | // validate |
1777 | - if($sourceId == '' && $sourceScreenName == '') throw new TwitterException('Specify an sourceId or a sourceScreenName.'); |
|
1778 | - if($targetId == '' && $targetScreenName == '') throw new TwitterException('Specify an targetId or a targetScreenName.'); |
|
1777 | + if ($sourceId == '' && $sourceScreenName == '') throw new TwitterException('Specify an sourceId or a sourceScreenName.'); |
|
1778 | + if ($targetId == '' && $targetScreenName == '') throw new TwitterException('Specify an targetId or a targetScreenName.'); |
|
1779 | 1779 | |
1780 | 1780 | // build parameters |
1781 | - if($sourceId != null) $parameters['source_id'] = (string) $sourceId; |
|
1782 | - if($sourceScreenName != null) $parameters['source_screen_name'] = (string) $sourceScreenName; |
|
1783 | - if($targetId != null) $parameters['target_id'] = (string) $targetId; |
|
1784 | - if($targetScreenName != null) $parameters['target_screen_name'] = (string) $targetScreenName; |
|
1781 | + if ($sourceId != null) $parameters['source_id'] = (string) $sourceId; |
|
1782 | + if ($sourceScreenName != null) $parameters['source_screen_name'] = (string) $sourceScreenName; |
|
1783 | + if ($targetId != null) $parameters['target_id'] = (string) $targetId; |
|
1784 | + if ($targetScreenName != null) $parameters['target_screen_name'] = (string) $targetScreenName; |
|
1785 | 1785 | |
1786 | 1786 | // make the call |
1787 | 1787 | return (array) $this->doCall('friendships/show.json', $parameters); |
@@ -1797,7 +1797,7 @@ discard block |
||
1797 | 1797 | public function friendshipsIncoming($cursor = null) |
1798 | 1798 | { |
1799 | 1799 | $parameters = null; |
1800 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1800 | + if ($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1801 | 1801 | |
1802 | 1802 | // make the call |
1803 | 1803 | return (array) $this->doCall('friendships/incoming.json', $parameters, true); |
@@ -1813,7 +1813,7 @@ discard block |
||
1813 | 1813 | public function friendshipsOutgoing($cursor = null) |
1814 | 1814 | { |
1815 | 1815 | $parameters = null; |
1816 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1816 | + if ($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1817 | 1817 | |
1818 | 1818 | // make the call |
1819 | 1819 | return (array) $this->doCall('friendships/outgoing.json', $parameters, true); |
@@ -1833,13 +1833,13 @@ discard block |
||
1833 | 1833 | public function friendsIds($id = null, $userId = null, $screenName = null, $cursor = null) |
1834 | 1834 | { |
1835 | 1835 | // validate |
1836 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1836 | + if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1837 | 1837 | |
1838 | 1838 | // build parameters |
1839 | - if($id != null) $parameters['id'] = (string) $id; |
|
1840 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1841 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1842 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1839 | + if ($id != null) $parameters['id'] = (string) $id; |
|
1840 | + if ($userId != null) $parameters['user_id'] = (string) $userId; |
|
1841 | + if ($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1842 | + if ($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1843 | 1843 | |
1844 | 1844 | // make the call |
1845 | 1845 | return (array) $this->doCall('friends/ids.json', $parameters); |
@@ -1858,13 +1858,13 @@ discard block |
||
1858 | 1858 | public function followersIds($id = null, $userId = null, $screenName = null, $cursor = null) |
1859 | 1859 | { |
1860 | 1860 | // validate |
1861 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1861 | + if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1862 | 1862 | |
1863 | 1863 | // build parameters |
1864 | - if($id != null) $parameters['id'] = (string) $id; |
|
1865 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1866 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1867 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1864 | + if ($id != null) $parameters['id'] = (string) $id; |
|
1865 | + if ($userId != null) $parameters['user_id'] = (string) $userId; |
|
1866 | + if ($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1867 | + if ($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1868 | 1868 | |
1869 | 1869 | // make the call |
1870 | 1870 | return (array) $this->doCall('followers/ids.json', $parameters); |
@@ -1909,9 +1909,9 @@ discard block |
||
1909 | 1909 | } |
1910 | 1910 | |
1911 | 1911 | // catch exceptions |
1912 | - catch(TwitterException $e) |
|
1912 | + catch (TwitterException $e) |
|
1913 | 1913 | { |
1914 | - if($e->getMessage() == 'Logged out.') return true; |
|
1914 | + if ($e->getMessage() == 'Logged out.') return true; |
|
1915 | 1915 | else throw $e; |
1916 | 1916 | } |
1917 | 1917 | } |
@@ -1947,14 +1947,14 @@ discard block |
||
1947 | 1947 | public function accountUpdateProfileColors($profileBackgroundColor = null, $profileTextColor = null, $profileLinkColor = null, $profileSidebarFillColor = null, $profileSidebarBorderColor = null) |
1948 | 1948 | { |
1949 | 1949 | // validate |
1950 | - if($profileBackgroundColor == '' && $profileTextColor == '' && $profileLinkColor == '' && $profileSidebarFillColor == '' && $profileSidebarBorderColor == '') throw new TwitterException('Specify a profileBackgroundColor, profileTextColor, profileLinkColor, profileSidebarFillColor or a profileSidebarBorderColor.'); |
|
1950 | + if ($profileBackgroundColor == '' && $profileTextColor == '' && $profileLinkColor == '' && $profileSidebarFillColor == '' && $profileSidebarBorderColor == '') throw new TwitterException('Specify a profileBackgroundColor, profileTextColor, profileLinkColor, profileSidebarFillColor or a profileSidebarBorderColor.'); |
|
1951 | 1951 | |
1952 | 1952 | // build parameters |
1953 | - if($profileBackgroundColor != null) $parameters['profile_background_color'] = (string) $profileBackgroundColor; |
|
1954 | - if($profileTextColor != null) $parameters['profile_text_color'] = (string) $profileTextColor; |
|
1955 | - if($profileLinkColor != null) $parameters['profile_link_color'] = (string) $profileLinkColor; |
|
1956 | - if($profileSidebarFillColor != null) $parameters['profile_sidebar_fill_color'] = (string) $profileSidebarFillColor; |
|
1957 | - if($profileSidebarBorderColor != null) $parameters['profile_sidebar_border_color'] = (string) $profileSidebarBorderColor; |
|
1953 | + if ($profileBackgroundColor != null) $parameters['profile_background_color'] = (string) $profileBackgroundColor; |
|
1954 | + if ($profileTextColor != null) $parameters['profile_text_color'] = (string) $profileTextColor; |
|
1955 | + if ($profileLinkColor != null) $parameters['profile_link_color'] = (string) $profileLinkColor; |
|
1956 | + if ($profileSidebarFillColor != null) $parameters['profile_sidebar_fill_color'] = (string) $profileSidebarFillColor; |
|
1957 | + if ($profileSidebarBorderColor != null) $parameters['profile_sidebar_border_color'] = (string) $profileSidebarBorderColor; |
|
1958 | 1958 | |
1959 | 1959 | // make the call |
1960 | 1960 | return (array) $this->doCall('account/update_profile_colors.json', $parameters, true, 'POST'); |
@@ -1972,7 +1972,7 @@ discard block |
||
1972 | 1972 | throw new TwitterException('Not implemented'); |
1973 | 1973 | |
1974 | 1974 | // validate |
1975 | - if(!file_exists($image)) throw new TwitterException('Image ('. $image .') doesn\'t exists.'); |
|
1975 | + if (!file_exists($image)) throw new TwitterException('Image ('.$image.') doesn\'t exists.'); |
|
1976 | 1976 | |
1977 | 1977 | // make the call |
1978 | 1978 | return (array) $this->doCall('account/update_profile_image.json', null, true, 'POST', $image); |
@@ -1991,10 +1991,10 @@ discard block |
||
1991 | 1991 | throw new TwitterException('Not implemented'); |
1992 | 1992 | |
1993 | 1993 | // validate |
1994 | - if(!file_exists($image)) throw new TwitterException('Image ('. $image .') doesn\'t exists.'); |
|
1994 | + if (!file_exists($image)) throw new TwitterException('Image ('.$image.') doesn\'t exists.'); |
|
1995 | 1995 | |
1996 | 1996 | // build parameters |
1997 | - if($tile) $parameters['tile'] = 'true'; |
|
1997 | + if ($tile) $parameters['tile'] = 'true'; |
|
1998 | 1998 | |
1999 | 1999 | // make the call |
2000 | 2000 | return (array) $this->doCall('account/update_profile_background_image.json', $parameters, true, 'POST', $image); |
@@ -2014,10 +2014,10 @@ discard block |
||
2014 | 2014 | { |
2015 | 2015 | // build parameters |
2016 | 2016 | $parameters = null; |
2017 | - if($name != null) $parameters['name'] = (string) $name; |
|
2018 | - if($url != null) $parameters['url'] = (string) $url; |
|
2019 | - if($location != null) $parameters['location'] = (string) $location; |
|
2020 | - if($description != null) $parameters['description'] = (string) $description; |
|
2017 | + if ($name != null) $parameters['name'] = (string) $name; |
|
2018 | + if ($url != null) $parameters['url'] = (string) $url; |
|
2019 | + if ($location != null) $parameters['location'] = (string) $location; |
|
2020 | + if ($description != null) $parameters['description'] = (string) $description; |
|
2021 | 2021 | |
2022 | 2022 | // make the call |
2023 | 2023 | return (array) $this->doCall('account/update_profile.json', $parameters, true, 'POST'); |
@@ -2036,8 +2036,8 @@ discard block |
||
2036 | 2036 | { |
2037 | 2037 | // build parameters |
2038 | 2038 | $parameters = null; |
2039 | - if($id != null) $parameters['id'] = (string) $id; |
|
2040 | - if($page != null) $parameters['page'] = (int) $page; |
|
2039 | + if ($id != null) $parameters['id'] = (string) $id; |
|
2040 | + if ($page != null) $parameters['page'] = (int) $page; |
|
2041 | 2041 | |
2042 | 2042 | // make the call |
2043 | 2043 | return (array) $this->doCall('favorites.json', $parameters, true); |
@@ -2053,7 +2053,7 @@ discard block |
||
2053 | 2053 | public function favoritesCreate($id) |
2054 | 2054 | { |
2055 | 2055 | // make the call |
2056 | - return (array) $this->doCall('favorites/create/'. $id .'.json', null, true, 'POST'); |
|
2056 | + return (array) $this->doCall('favorites/create/'.$id.'.json', null, true, 'POST'); |
|
2057 | 2057 | } |
2058 | 2058 | |
2059 | 2059 | |
@@ -2066,7 +2066,7 @@ discard block |
||
2066 | 2066 | public function favoritesDestroy($id) |
2067 | 2067 | { |
2068 | 2068 | // make the call |
2069 | - return (array) $this->doCall('favorites/destroy/'. $id .'.json', null, true, 'POST'); |
|
2069 | + return (array) $this->doCall('favorites/destroy/'.$id.'.json', null, true, 'POST'); |
|
2070 | 2070 | } |
2071 | 2071 | |
2072 | 2072 | |
@@ -2082,12 +2082,12 @@ discard block |
||
2082 | 2082 | public function notificationsFollow($id = null, $userId = null, $screenName = null) |
2083 | 2083 | { |
2084 | 2084 | // validate |
2085 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2085 | + if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2086 | 2086 | |
2087 | 2087 | // build parameters |
2088 | - if($id != null) $parameters['id'] = (string) $id; |
|
2089 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
2090 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2088 | + if ($id != null) $parameters['id'] = (string) $id; |
|
2089 | + if ($userId != null) $parameters['user_id'] = (string) $userId; |
|
2090 | + if ($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2091 | 2091 | |
2092 | 2092 | // make the call |
2093 | 2093 | return (array) $this->doCall('notifications/follow.json', $parameters, true, 'POST'); |
@@ -2105,12 +2105,12 @@ discard block |
||
2105 | 2105 | public function notificationsLeave($id = null, $userId = null, $screenName = null) |
2106 | 2106 | { |
2107 | 2107 | // validate |
2108 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2108 | + if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2109 | 2109 | |
2110 | 2110 | // build parameters |
2111 | - if($id != null) $parameters['id'] = (string) $id; |
|
2112 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
2113 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2111 | + if ($id != null) $parameters['id'] = (string) $id; |
|
2112 | + if ($userId != null) $parameters['user_id'] = (string) $userId; |
|
2113 | + if ($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2114 | 2114 | |
2115 | 2115 | // make the call |
2116 | 2116 | return (array) $this->doCall('notifications/leave.json', $parameters, true, 'POST'); |
@@ -2129,12 +2129,12 @@ discard block |
||
2129 | 2129 | public function blocksCreate($id = null, $userId = null, $screenName = null) |
2130 | 2130 | { |
2131 | 2131 | // validate |
2132 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2132 | + if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2133 | 2133 | |
2134 | 2134 | // build parameters |
2135 | - if($id != null) $parameters['id'] = (string) $id; |
|
2136 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
2137 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2135 | + if ($id != null) $parameters['id'] = (string) $id; |
|
2136 | + if ($userId != null) $parameters['user_id'] = (string) $userId; |
|
2137 | + if ($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2138 | 2138 | |
2139 | 2139 | // make the call |
2140 | 2140 | return (array) $this->doCall('blocks/create.json', $parameters, true, 'POST'); |
@@ -2152,12 +2152,12 @@ discard block |
||
2152 | 2152 | public function blocksDestroy($id = null, $userId = null, $screenName = null) |
2153 | 2153 | { |
2154 | 2154 | // validate |
2155 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2155 | + if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2156 | 2156 | |
2157 | 2157 | // build parameters |
2158 | - if($id != null) $parameters['id'] = (string) $id; |
|
2159 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
2160 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2158 | + if ($id != null) $parameters['id'] = (string) $id; |
|
2159 | + if ($userId != null) $parameters['user_id'] = (string) $userId; |
|
2160 | + if ($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2161 | 2161 | |
2162 | 2162 | // make the call |
2163 | 2163 | return (array) $this->doCall('blocks/destroy.json', $parameters, true, 'POST'); |
@@ -2175,12 +2175,12 @@ discard block |
||
2175 | 2175 | public function blocksExists($id = null, $userId = null, $screenName = null) |
2176 | 2176 | { |
2177 | 2177 | // validate |
2178 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2178 | + if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2179 | 2179 | |
2180 | 2180 | // build parameters |
2181 | - if($id != null) $parameters['id'] = (string) $id; |
|
2182 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
2183 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2181 | + if ($id != null) $parameters['id'] = (string) $id; |
|
2182 | + if ($userId != null) $parameters['user_id'] = (string) $userId; |
|
2183 | + if ($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2184 | 2184 | |
2185 | 2185 | try |
2186 | 2186 | { |
@@ -2188,9 +2188,9 @@ discard block |
||
2188 | 2188 | return (array) $this->doCall('blocks/exists.json', $parameters, true); |
2189 | 2189 | } |
2190 | 2190 | // catch exceptions |
2191 | - catch(TwitterException $e) |
|
2191 | + catch (TwitterException $e) |
|
2192 | 2192 | { |
2193 | - if($e->getMessage() == 'You are not blocking this user.') return false; |
|
2193 | + if ($e->getMessage() == 'You are not blocking this user.') return false; |
|
2194 | 2194 | else throw $e; |
2195 | 2195 | } |
2196 | 2196 | } |
@@ -2206,7 +2206,7 @@ discard block |
||
2206 | 2206 | { |
2207 | 2207 | // build parameters |
2208 | 2208 | $parameters = null; |
2209 | - if($page != null) $parameters['page'] = (int) $page; |
|
2209 | + if ($page != null) $parameters['page'] = (int) $page; |
|
2210 | 2210 | |
2211 | 2211 | // make the call |
2212 | 2212 | return (array) $this->doCall('blocks/blocking.json', $parameters, true); |
@@ -2237,12 +2237,12 @@ discard block |
||
2237 | 2237 | public function reportSpam($id = null, $userId = null, $screenName = null) |
2238 | 2238 | { |
2239 | 2239 | // validate |
2240 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2240 | + if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2241 | 2241 | |
2242 | 2242 | // build parameters |
2243 | - if($id != null) $parameters['id'] = (string) $id; |
|
2244 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
2245 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2243 | + if ($id != null) $parameters['id'] = (string) $id; |
|
2244 | + if ($userId != null) $parameters['user_id'] = (string) $userId; |
|
2245 | + if ($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2246 | 2246 | |
2247 | 2247 | // make the call |
2248 | 2248 | return (array) $this->doCall('report_spam.json', $parameters, true, 'POST'); |
@@ -2303,7 +2303,7 @@ discard block |
||
2303 | 2303 | */ |
2304 | 2304 | public function savedSearchesDestroy($id) |
2305 | 2305 | { |
2306 | - return (array) $this->doCall('saved_searches/destroy/'. (string) $id .'.json', null, true, 'POST'); |
|
2306 | + return (array) $this->doCall('saved_searches/destroy/'.(string) $id.'.json', null, true, 'POST'); |
|
2307 | 2307 | } |
2308 | 2308 | |
2309 | 2309 | |
@@ -2321,17 +2321,17 @@ discard block |
||
2321 | 2321 | $parameters = array(); |
2322 | 2322 | |
2323 | 2323 | // set callback |
2324 | - if($callbackURL != null) $parameters['oauth_callback'] = (string) $callbackURL; |
|
2324 | + if ($callbackURL != null) $parameters['oauth_callback'] = (string) $callbackURL; |
|
2325 | 2325 | |
2326 | 2326 | // make the call |
2327 | 2327 | $response = $this->doOAuthCall('request_token', $parameters); |
2328 | 2328 | |
2329 | 2329 | // validate |
2330 | - if(!isset($response['oauth_token'], $response['oauth_token_secret'])) throw new TwitterException(implode(', ', array_keys($response))); |
|
2330 | + if (!isset($response['oauth_token'], $response['oauth_token_secret'])) throw new TwitterException(implode(', ', array_keys($response))); |
|
2331 | 2331 | |
2332 | 2332 | // set some properties |
2333 | - if(isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']); |
|
2334 | - if(isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']); |
|
2333 | + if (isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']); |
|
2334 | + if (isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']); |
|
2335 | 2335 | |
2336 | 2336 | // return |
2337 | 2337 | return $response; |
@@ -2357,8 +2357,8 @@ discard block |
||
2357 | 2357 | $response = $this->doOAuthCall('access_token', $parameters); |
2358 | 2358 | |
2359 | 2359 | // set some properties |
2360 | - if(isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']); |
|
2361 | - if(isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']); |
|
2360 | + if (isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']); |
|
2361 | + if (isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']); |
|
2362 | 2362 | |
2363 | 2363 | // return |
2364 | 2364 | return $response; |
@@ -2372,7 +2372,7 @@ discard block |
||
2372 | 2372 | */ |
2373 | 2373 | public function oAuthAuthorize() |
2374 | 2374 | { |
2375 | - header('Location: '. self::SECURE_API_URL .'/oauth/authorize?oauth_token='. $this->oAuthToken); |
|
2375 | + header('Location: '.self::SECURE_API_URL.'/oauth/authorize?oauth_token='.$this->oAuthToken); |
|
2376 | 2376 | } |
2377 | 2377 | |
2378 | 2378 | |
@@ -2403,8 +2403,8 @@ discard block |
||
2403 | 2403 | { |
2404 | 2404 | // build parameters |
2405 | 2405 | $parameters = null; |
2406 | - if($lat != null) $parameters['lat_for_trends'] = (float) $lat; |
|
2407 | - if($long != null) $parameters['long_for_trends'] = (float) $long; |
|
2406 | + if ($lat != null) $parameters['lat_for_trends'] = (float) $lat; |
|
2407 | + if ($long != null) $parameters['long_for_trends'] = (float) $long; |
|
2408 | 2408 | |
2409 | 2409 | // make the call |
2410 | 2410 | return (array) $this->doCall('trends/available.json', $parameters); |
@@ -2423,7 +2423,7 @@ discard block |
||
2423 | 2423 | public function trendsLocation($woeid) |
2424 | 2424 | { |
2425 | 2425 | // make the call |
2426 | - return (array) $this->doCall('trends/location/'. (string) $woeid .'.json'); |
|
2426 | + return (array) $this->doCall('trends/location/'.(string) $woeid.'.json'); |
|
2427 | 2427 | } |
2428 | 2428 | |
2429 | 2429 | |
@@ -2446,9 +2446,9 @@ discard block |
||
2446 | 2446 | // build parameters |
2447 | 2447 | $parameters['lat'] = (float) $lat; |
2448 | 2448 | $parameters['long'] = (float) $long; |
2449 | - if($accuracy != null) $parameters['accuracy'] = (string) $accuracy; |
|
2450 | - if($granularity != null) $parameters['granularity'] = (string) $granularity; |
|
2451 | - if($maxResults != null) $parameters['max_results'] = (int) $maxResults; |
|
2449 | + if ($accuracy != null) $parameters['accuracy'] = (string) $accuracy; |
|
2450 | + if ($granularity != null) $parameters['granularity'] = (string) $granularity; |
|
2451 | + if ($maxResults != null) $parameters['max_results'] = (int) $maxResults; |
|
2452 | 2452 | |
2453 | 2453 | // make the call |
2454 | 2454 | return (array) $this->doCall('geo/reverse_geocode.json', $parameters); |
@@ -2466,10 +2466,10 @@ discard block |
||
2466 | 2466 | { |
2467 | 2467 | // build parameters |
2468 | 2468 | $parameters = null; |
2469 | - if($placeId != null) $parameters['place_id'] = (string) $placeId; |
|
2469 | + if ($placeId != null) $parameters['place_id'] = (string) $placeId; |
|
2470 | 2470 | |
2471 | 2471 | // make the call |
2472 | - return (array) $this->doCall('geo/id/'. (string) $id .'.json', $parameters); |
|
2472 | + return (array) $this->doCall('geo/id/'.(string) $id.'.json', $parameters); |
|
2473 | 2473 | } |
2474 | 2474 | |
2475 | 2475 |
@@ -134,7 +134,9 @@ discard block |
||
134 | 134 | */ |
135 | 135 | public function __destruct() |
136 | 136 | { |
137 | - if($this->curl != null) curl_close($this->curl); |
|
137 | + if($this->curl != null) { |
|
138 | + curl_close($this->curl); |
|
139 | + } |
|
138 | 140 | } |
139 | 141 | |
140 | 142 | |
@@ -147,7 +149,9 @@ discard block |
||
147 | 149 | private function buildQuery(array $parameters) |
148 | 150 | { |
149 | 151 | // no parameters? |
150 | - if(empty($parameters)) return ''; |
|
152 | + if(empty($parameters)) { |
|
153 | + return ''; |
|
154 | + } |
|
151 | 155 | |
152 | 156 | // encode the keys |
153 | 157 | $keys = self::urlencode_rfc3986(array_keys($parameters)); |
@@ -165,11 +169,15 @@ discard block |
||
165 | 169 | foreach($parameters as $key => $value) |
166 | 170 | { |
167 | 171 | // sort by value |
168 | - if(is_array($value)) $parameters[$key] = natsort($value); |
|
172 | + if(is_array($value)) { |
|
173 | + $parameters[$key] = natsort($value); |
|
174 | + } |
|
169 | 175 | } |
170 | 176 | |
171 | 177 | // process parameters |
172 | - foreach($parameters as $key => $value) $chunks[] = $key .'='. str_replace('%25', '%', $value); |
|
178 | + foreach($parameters as $key => $value) { |
|
179 | + $chunks[] = $key .'='. str_replace('%25', '%', $value); |
|
180 | + } |
|
173 | 181 | |
174 | 182 | // return |
175 | 183 | return implode('&', $chunks); |
@@ -208,7 +216,9 @@ discard block |
||
208 | 216 | foreach($parameters as $key => $value) |
209 | 217 | { |
210 | 218 | // sort by value |
211 | - if(is_array($value)) $parameters[$key] = natsort($value); |
|
219 | + if(is_array($value)) { |
|
220 | + $parameters[$key] = natsort($value); |
|
221 | + } |
|
212 | 222 | } |
213 | 223 | |
214 | 224 | // process queries |
@@ -246,7 +256,9 @@ discard block |
||
246 | 256 | $chunks = array(); |
247 | 257 | |
248 | 258 | // process queries |
249 | - foreach($parameters as $key => $value) $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) .'="'. self::urlencode_rfc3986($value) .'"'); |
|
259 | + foreach($parameters as $key => $value) { |
|
260 | + $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) .'="'. self::urlencode_rfc3986($value) .'"'); |
|
261 | + } |
|
250 | 262 | |
251 | 263 | // build return |
252 | 264 | $return = 'Authorization: OAuth realm="' . $parts['scheme'] . '://' . $parts['host'] . $parts['path'] . '", '; |
@@ -300,7 +312,9 @@ discard block |
||
300 | 312 | $options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters); |
301 | 313 | |
302 | 314 | // init |
303 | - if($this->curl == null) $this->curl = curl_init(); |
|
315 | + if($this->curl == null) { |
|
316 | + $this->curl = curl_init(); |
|
317 | + } |
|
304 | 318 | |
305 | 319 | // set options |
306 | 320 | curl_setopt_array($this->curl, $options); |
@@ -314,7 +328,9 @@ discard block |
||
314 | 328 | $errorMessage = curl_error($this->curl); |
315 | 329 | |
316 | 330 | // error? |
317 | - if($errorNumber != '') throw new TwitterException($errorMessage, $errorNumber); |
|
331 | + if($errorNumber != '') { |
|
332 | + throw new TwitterException($errorMessage, $errorNumber); |
|
333 | + } |
|
318 | 334 | |
319 | 335 | // init var |
320 | 336 | $return = array(); |
@@ -349,7 +365,9 @@ discard block |
||
349 | 365 | $expectJSON = (bool) $expectJSON; |
350 | 366 | |
351 | 367 | // validate method |
352 | - if(!in_array($method, $allowedMethods)) throw new TwitterException('Unknown method ('. $method .'). Allowed methods are: '. implode(', ', $allowedMethods)); |
|
368 | + if(!in_array($method, $allowedMethods)) { |
|
369 | + throw new TwitterException('Unknown method ('. $method .'). Allowed methods are: '. implode(', ', $allowedMethods)); |
|
370 | + } |
|
353 | 371 | |
354 | 372 | // append default parameters |
355 | 373 | $oauth['oauth_consumer_key'] = $this->getConsumerKey(); |
@@ -361,7 +379,9 @@ discard block |
||
361 | 379 | |
362 | 380 | // set data |
363 | 381 | $data = $oauth; |
364 | - if(!empty($parameters)) $data = array_merge($data, $parameters); |
|
382 | + if(!empty($parameters)) { |
|
383 | + $data = array_merge($data, $parameters); |
|
384 | + } |
|
365 | 385 | |
366 | 386 | // calculate the base string |
367 | 387 | $base = $this->calculateBaseString(self::API_URL .'/'. $url, $method, $data); |
@@ -386,9 +406,13 @@ discard block |
||
386 | 406 | |
387 | 407 | // set mimeType |
388 | 408 | $mimeType = 'application/octet-stream'; |
389 | - if($fileInfo['extension'] == 'jpg' || $fileInfo['extension'] == 'jpeg') $mimeType = 'image/jpeg'; |
|
390 | - elseif($fileInfo['extension'] == 'gif') $mimeType = 'image/gif'; |
|
391 | - elseif($fileInfo['extension'] == 'png') $mimeType = 'image/png'; |
|
409 | + if($fileInfo['extension'] == 'jpg' || $fileInfo['extension'] == 'jpeg') { |
|
410 | + $mimeType = 'image/jpeg'; |
|
411 | + } elseif($fileInfo['extension'] == 'gif') { |
|
412 | + $mimeType = 'image/gif'; |
|
413 | + } elseif($fileInfo['extension'] == 'png') { |
|
414 | + $mimeType = 'image/png'; |
|
415 | + } |
|
392 | 416 | |
393 | 417 | // init var |
394 | 418 | $content = '--'. $boundary ."\r\n"; |
@@ -405,16 +429,18 @@ discard block |
||
405 | 429 | } |
406 | 430 | |
407 | 431 | // no file |
408 | - else $options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters); |
|
432 | + else { |
|
433 | + $options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters); |
|
434 | + } |
|
409 | 435 | |
410 | 436 | // enable post |
411 | 437 | $options[CURLOPT_POST] = 1; |
412 | - } |
|
413 | - |
|
414 | - else |
|
438 | + } else |
|
415 | 439 | { |
416 | 440 | // add the parameters into the querystring |
417 | - if(!empty($parameters)) $url .= '?'. $this->buildQuery($parameters); |
|
441 | + if(!empty($parameters)) { |
|
442 | + $url .= '?'. $this->buildQuery($parameters); |
|
443 | + } |
|
418 | 444 | } |
419 | 445 | |
420 | 446 | // set options |
@@ -430,7 +456,9 @@ discard block |
||
430 | 456 | $options[CURLOPT_HTTPHEADER] = $headers; |
431 | 457 | |
432 | 458 | // init |
433 | - if($this->curl == null) $this->curl = curl_init(); |
|
459 | + if($this->curl == null) { |
|
460 | + $this->curl = curl_init(); |
|
461 | + } |
|
434 | 462 | |
435 | 463 | // set options |
436 | 464 | curl_setopt_array($this->curl, $options); |
@@ -444,7 +472,9 @@ discard block |
||
444 | 472 | $errorMessage = curl_error($this->curl); |
445 | 473 | |
446 | 474 | // we don't expext JSON, return the response |
447 | - if(!$expectJSON) return $response; |
|
475 | + if(!$expectJSON) { |
|
476 | + return $response; |
|
477 | + } |
|
448 | 478 | |
449 | 479 | // replace ids with their string values, added because of some PHP-version can't handle these large values |
450 | 480 | $response = preg_replace('/id":(\d+)/', 'id":"\1"', $response); |
@@ -502,8 +532,11 @@ discard block |
||
502 | 532 | } |
503 | 533 | |
504 | 534 | // throw exception |
505 | - if(isset($json['errors'][0]['message'])) throw new TwitterException($json['errors'][0]['message']); |
|
506 | - else throw new TwitterException('Invalid response.'); |
|
535 | + if(isset($json['errors'][0]['message'])) { |
|
536 | + throw new TwitterException($json['errors'][0]['message']); |
|
537 | + } else { |
|
538 | + throw new TwitterException('Invalid response.'); |
|
539 | + } |
|
507 | 540 | } |
508 | 541 | |
509 | 542 | |
@@ -696,8 +729,9 @@ discard block |
||
696 | 729 | */ |
697 | 730 | private static function urlencode_rfc3986($value) |
698 | 731 | { |
699 | - if(is_array($value)) return array_map(array('Twitter', 'urlencode_rfc3986'), $value); |
|
700 | - else |
|
732 | + if(is_array($value)) { |
|
733 | + return array_map(array('Twitter', 'urlencode_rfc3986'), $value); |
|
734 | + } else |
|
701 | 735 | { |
702 | 736 | $search = array('+', ' ', '%7E', '%'); |
703 | 737 | $replace = array('%20', '%20', '~', '%25'); |
@@ -722,7 +756,9 @@ discard block |
||
722 | 756 | |
723 | 757 | // build parameters |
724 | 758 | $parameters = array(); |
725 | - if($skipUser) $parameters['skip_user'] = 'true'; |
|
759 | + if($skipUser) { |
|
760 | + $parameters['skip_user'] = 'true'; |
|
761 | + } |
|
726 | 762 | |
727 | 763 | // make the call |
728 | 764 | return (array) $this->doCall('statuses/public_timeline.json', $parameters); |
@@ -746,11 +782,21 @@ discard block |
||
746 | 782 | |
747 | 783 | // build parameters |
748 | 784 | $parameters = array(); |
749 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
750 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
751 | - if($count != null) $parameters['count'] = (int) $count; |
|
752 | - if($page != null) $parameters['page'] = (int) $page; |
|
753 | - if($skipUser) $parameters['skip_user'] = 'true'; |
|
785 | + if($sinceId != null) { |
|
786 | + $parameters['since_id'] = (string) $sinceId; |
|
787 | + } |
|
788 | + if($maxId != null) { |
|
789 | + $parameters['max_id'] = (string) $maxId; |
|
790 | + } |
|
791 | + if($count != null) { |
|
792 | + $parameters['count'] = (int) $count; |
|
793 | + } |
|
794 | + if($page != null) { |
|
795 | + $parameters['page'] = (int) $page; |
|
796 | + } |
|
797 | + if($skipUser) { |
|
798 | + $parameters['skip_user'] = 'true'; |
|
799 | + } |
|
754 | 800 | |
755 | 801 | // make the call |
756 | 802 | return (array) $this->doCall('statuses/home_timeline.json', $parameters, true); |
@@ -778,11 +824,21 @@ discard block |
||
778 | 824 | |
779 | 825 | // build parameters |
780 | 826 | $parameters = array(); |
781 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
782 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
783 | - if($count != null) $parameters['count'] = (int) $count; |
|
784 | - if($page != null) $parameters['page'] = (int) $page; |
|
785 | - if($skipUser) $parameters['skip_user'] = 'true'; |
|
827 | + if($sinceId != null) { |
|
828 | + $parameters['since_id'] = (string) $sinceId; |
|
829 | + } |
|
830 | + if($maxId != null) { |
|
831 | + $parameters['max_id'] = (string) $maxId; |
|
832 | + } |
|
833 | + if($count != null) { |
|
834 | + $parameters['count'] = (int) $count; |
|
835 | + } |
|
836 | + if($page != null) { |
|
837 | + $parameters['page'] = (int) $page; |
|
838 | + } |
|
839 | + if($skipUser) { |
|
840 | + $parameters['skip_user'] = 'true'; |
|
841 | + } |
|
786 | 842 | |
787 | 843 | // make the call |
788 | 844 | return (array) $this->doCall('statuses/friends_timeline.json', $parameters, true); |
@@ -813,14 +869,30 @@ discard block |
||
813 | 869 | |
814 | 870 | // build parameters |
815 | 871 | $parameters = array(); |
816 | - if($id != null) $parameters['id'] = (string) $id; |
|
817 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
818 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
819 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
820 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
821 | - if($count != null) $parameters['count'] = (int) $count; |
|
822 | - if($page != null) $parameters['page'] = (int) $page; |
|
823 | - if($skipUser) $parameters['skip_user'] = 'true'; |
|
872 | + if($id != null) { |
|
873 | + $parameters['id'] = (string) $id; |
|
874 | + } |
|
875 | + if($userId != null) { |
|
876 | + $parameters['user_id'] = (string) $userId; |
|
877 | + } |
|
878 | + if($screenName != null) { |
|
879 | + $parameters['screen_name'] = (string) $screenName; |
|
880 | + } |
|
881 | + if($sinceId != null) { |
|
882 | + $parameters['since_id'] = (string) $sinceId; |
|
883 | + } |
|
884 | + if($maxId != null) { |
|
885 | + $parameters['max_id'] = (string) $maxId; |
|
886 | + } |
|
887 | + if($count != null) { |
|
888 | + $parameters['count'] = (int) $count; |
|
889 | + } |
|
890 | + if($page != null) { |
|
891 | + $parameters['page'] = (int) $page; |
|
892 | + } |
|
893 | + if($skipUser) { |
|
894 | + $parameters['skip_user'] = 'true'; |
|
895 | + } |
|
824 | 896 | |
825 | 897 | // make the call |
826 | 898 | return (array) $this->doCall('statuses/user_timeline.json', $parameters, true); |
@@ -839,14 +911,24 @@ discard block |
||
839 | 911 | public function statusesMentions($sinceId = null, $maxId = null, $count = null, $page = null) |
840 | 912 | { |
841 | 913 | // validate |
842 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
914 | + if($count != null && $count > 200) { |
|
915 | + throw new TwitterException('Count may not be greater than 200.'); |
|
916 | + } |
|
843 | 917 | |
844 | 918 | // build parameters |
845 | 919 | $parameters = array(); |
846 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
847 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
848 | - if($count != null) $parameters['count'] = (int) $count; |
|
849 | - if($page != null) $parameters['page'] = (int) $page; |
|
920 | + if($sinceId != null) { |
|
921 | + $parameters['since_id'] = (string) $sinceId; |
|
922 | + } |
|
923 | + if($maxId != null) { |
|
924 | + $parameters['max_id'] = (string) $maxId; |
|
925 | + } |
|
926 | + if($count != null) { |
|
927 | + $parameters['count'] = (int) $count; |
|
928 | + } |
|
929 | + if($page != null) { |
|
930 | + $parameters['page'] = (int) $page; |
|
931 | + } |
|
850 | 932 | |
851 | 933 | // make the call |
852 | 934 | return (array) $this->doCall('statuses/mentions.json', $parameters); |
@@ -865,14 +947,24 @@ discard block |
||
865 | 947 | public function statusesRetweetedByMe($sinceId = null, $maxId = null, $count = null, $page = null) |
866 | 948 | { |
867 | 949 | // validate |
868 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
950 | + if($count != null && $count > 200) { |
|
951 | + throw new TwitterException('Count may not be greater than 200.'); |
|
952 | + } |
|
869 | 953 | |
870 | 954 | // build parameters |
871 | 955 | $parameters = array(); |
872 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
873 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
874 | - if($count != null) $parameters['count'] = (int) $count; |
|
875 | - if($page != null) $parameters['page'] = (int) $page; |
|
956 | + if($sinceId != null) { |
|
957 | + $parameters['since_id'] = (string) $sinceId; |
|
958 | + } |
|
959 | + if($maxId != null) { |
|
960 | + $parameters['max_id'] = (string) $maxId; |
|
961 | + } |
|
962 | + if($count != null) { |
|
963 | + $parameters['count'] = (int) $count; |
|
964 | + } |
|
965 | + if($page != null) { |
|
966 | + $parameters['page'] = (int) $page; |
|
967 | + } |
|
876 | 968 | |
877 | 969 | // make the call |
878 | 970 | return (array) $this->doCall('statuses/retweeted_by_me.json', $parameters); |
@@ -891,14 +983,24 @@ discard block |
||
891 | 983 | public function statusesRetweetedToMe($sinceId = null, $maxId = null, $count = null, $page = null) |
892 | 984 | { |
893 | 985 | // validate |
894 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
986 | + if($count != null && $count > 200) { |
|
987 | + throw new TwitterException('Count may not be greater than 200.'); |
|
988 | + } |
|
895 | 989 | |
896 | 990 | // build parameters |
897 | 991 | $parameters = array(); |
898 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
899 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
900 | - if($count != null) $parameters['count'] = (int) $count; |
|
901 | - if($page != null) $parameters['page'] = (int) $page; |
|
992 | + if($sinceId != null) { |
|
993 | + $parameters['since_id'] = (string) $sinceId; |
|
994 | + } |
|
995 | + if($maxId != null) { |
|
996 | + $parameters['max_id'] = (string) $maxId; |
|
997 | + } |
|
998 | + if($count != null) { |
|
999 | + $parameters['count'] = (int) $count; |
|
1000 | + } |
|
1001 | + if($page != null) { |
|
1002 | + $parameters['page'] = (int) $page; |
|
1003 | + } |
|
902 | 1004 | |
903 | 1005 | // make the call |
904 | 1006 | return (array) $this->doCall('statuses/retweeted_by_me.json', $parameters); |
@@ -918,14 +1020,24 @@ discard block |
||
918 | 1020 | public function statusesReweetsOfMe($sinceId = null, $maxId = null, $count = null, $page = null) |
919 | 1021 | { |
920 | 1022 | // validate |
921 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1023 | + if($count != null && $count > 200) { |
|
1024 | + throw new TwitterException('Count may not be greater than 200.'); |
|
1025 | + } |
|
922 | 1026 | |
923 | 1027 | // build parameters |
924 | 1028 | $parameters = array(); |
925 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
926 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
927 | - if($count != null) $parameters['count'] = (int) $count; |
|
928 | - if($page != null) $parameters['page'] = (int) $page; |
|
1029 | + if($sinceId != null) { |
|
1030 | + $parameters['since_id'] = (string) $sinceId; |
|
1031 | + } |
|
1032 | + if($maxId != null) { |
|
1033 | + $parameters['max_id'] = (string) $maxId; |
|
1034 | + } |
|
1035 | + if($count != null) { |
|
1036 | + $parameters['count'] = (int) $count; |
|
1037 | + } |
|
1038 | + if($page != null) { |
|
1039 | + $parameters['page'] = (int) $page; |
|
1040 | + } |
|
929 | 1041 | |
930 | 1042 | // make the call |
931 | 1043 | return (array) $this->doCall('statuses/retweets_of_me.json', $parameters); |
@@ -963,11 +1075,21 @@ discard block |
||
963 | 1075 | { |
964 | 1076 | // build parameters |
965 | 1077 | $parameters['status'] = (string) $status; |
966 | - if($inReplyToStatusId != null) $parameters['in_reply_to_status_id'] = (string) $inReplyToStatusId; |
|
967 | - if($lat != null) $parameters['lat'] = (float) $lat; |
|
968 | - if($long != null) $parameters['long'] = (float) $long; |
|
969 | - if($placeId != null) $parameters['place_id'] = (string) $placeId; |
|
970 | - if($displayCoordinates) $parameters['display_coordinates'] = 'true'; |
|
1078 | + if($inReplyToStatusId != null) { |
|
1079 | + $parameters['in_reply_to_status_id'] = (string) $inReplyToStatusId; |
|
1080 | + } |
|
1081 | + if($lat != null) { |
|
1082 | + $parameters['lat'] = (float) $lat; |
|
1083 | + } |
|
1084 | + if($long != null) { |
|
1085 | + $parameters['long'] = (float) $long; |
|
1086 | + } |
|
1087 | + if($placeId != null) { |
|
1088 | + $parameters['place_id'] = (string) $placeId; |
|
1089 | + } |
|
1090 | + if($displayCoordinates) { |
|
1091 | + $parameters['display_coordinates'] = 'true'; |
|
1092 | + } |
|
971 | 1093 | |
972 | 1094 | // make the call |
973 | 1095 | return (array) $this->doCall('statuses/update.json', $parameters, true, 'POST'); |
@@ -1015,11 +1137,15 @@ discard block |
||
1015 | 1137 | public function statusesRetweets($id, $count = null) |
1016 | 1138 | { |
1017 | 1139 | // validate |
1018 | - if($count != null && $count > 100) throw new TwitterException('Count may not be greater than 100.'); |
|
1140 | + if($count != null && $count > 100) { |
|
1141 | + throw new TwitterException('Count may not be greater than 100.'); |
|
1142 | + } |
|
1019 | 1143 | |
1020 | 1144 | // build parameters |
1021 | 1145 | $parameters = null; |
1022 | - if($count != null) $parameters['count'] = (int) $count; |
|
1146 | + if($count != null) { |
|
1147 | + $parameters['count'] = (int) $count; |
|
1148 | + } |
|
1023 | 1149 | |
1024 | 1150 | // make the call |
1025 | 1151 | return (array) $this->doCall('statuses/retweets/'. $id .'.json', $parameters); |
@@ -1037,12 +1163,18 @@ discard block |
||
1037 | 1163 | public function statusesIdRetweetedBy($id, $count = null, $page = null) |
1038 | 1164 | { |
1039 | 1165 | // validate |
1040 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1166 | + if($count != null && $count > 200) { |
|
1167 | + throw new TwitterException('Count may not be greater than 200.'); |
|
1168 | + } |
|
1041 | 1169 | |
1042 | 1170 | // build parameters |
1043 | 1171 | $parameters = null; |
1044 | - if($count != null) $parameters['count'] = (int) $count; |
|
1045 | - if($page != null) $parameters['page'] = (int) $page; |
|
1172 | + if($count != null) { |
|
1173 | + $parameters['count'] = (int) $count; |
|
1174 | + } |
|
1175 | + if($page != null) { |
|
1176 | + $parameters['page'] = (int) $page; |
|
1177 | + } |
|
1046 | 1178 | |
1047 | 1179 | // make the call |
1048 | 1180 | return (array) $this->doCall('statuses/'. (string) $id .'/retweeted_by.json', $parameters, true); |
@@ -1060,12 +1192,18 @@ discard block |
||
1060 | 1192 | public function statusesIdRetweetedByIds($id, $count = null, $page = null) |
1061 | 1193 | { |
1062 | 1194 | // validate |
1063 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1195 | + if($count != null && $count > 200) { |
|
1196 | + throw new TwitterException('Count may not be greater than 200.'); |
|
1197 | + } |
|
1064 | 1198 | |
1065 | 1199 | // build parameters |
1066 | 1200 | $parameters = null; |
1067 | - if($count != null) $parameters['count'] = (int) $count; |
|
1068 | - if($page != null) $parameters['page'] = (int) $page; |
|
1201 | + if($count != null) { |
|
1202 | + $parameters['count'] = (int) $count; |
|
1203 | + } |
|
1204 | + if($page != null) { |
|
1205 | + $parameters['page'] = (int) $page; |
|
1206 | + } |
|
1069 | 1207 | |
1070 | 1208 | // make the call |
1071 | 1209 | return (array) $this->doCall('statuses/'. (string) $id .'/retweeted_by/ids.json', $parameters, true); |
@@ -1085,12 +1223,20 @@ discard block |
||
1085 | 1223 | public function usersShow($id = null, $userId = null, $screenName = null) |
1086 | 1224 | { |
1087 | 1225 | // validate |
1088 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1226 | + if($id == '' && $userId == '' && $screenName == '') { |
|
1227 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1228 | + } |
|
1089 | 1229 | |
1090 | 1230 | // build parameters |
1091 | - if($id != null) $parameters['id'] = (string) $id; |
|
1092 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1093 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1231 | + if($id != null) { |
|
1232 | + $parameters['id'] = (string) $id; |
|
1233 | + } |
|
1234 | + if($userId != null) { |
|
1235 | + $parameters['user_id'] = (string) $userId; |
|
1236 | + } |
|
1237 | + if($screenName != null) { |
|
1238 | + $parameters['screen_name'] = (string) $screenName; |
|
1239 | + } |
|
1094 | 1240 | |
1095 | 1241 | // make the call |
1096 | 1242 | return (array) $this->doCall('users/show.json', $parameters); |
@@ -1112,11 +1258,17 @@ discard block |
||
1112 | 1258 | $screenNames = (array) $screenNames; |
1113 | 1259 | |
1114 | 1260 | // validate |
1115 | - if(empty($userIds) && empty($screenNames)) throw new TwitterException('Specify an userId or a screenName.'); |
|
1261 | + if(empty($userIds) && empty($screenNames)) { |
|
1262 | + throw new TwitterException('Specify an userId or a screenName.'); |
|
1263 | + } |
|
1116 | 1264 | |
1117 | 1265 | // build parameters |
1118 | - if(!empty($userIds)) $parameters['user_id'] = implode(',', $userIds); |
|
1119 | - if(!empty($screenNames)) $parameters['screen_name'] = implode(',', $screenNames); |
|
1266 | + if(!empty($userIds)) { |
|
1267 | + $parameters['user_id'] = implode(',', $userIds); |
|
1268 | + } |
|
1269 | + if(!empty($screenNames)) { |
|
1270 | + $parameters['screen_name'] = implode(',', $screenNames); |
|
1271 | + } |
|
1120 | 1272 | |
1121 | 1273 | // make the call |
1122 | 1274 | return (array) $this->doCall('users/lookup.json', $parameters, true); |
@@ -1137,8 +1289,12 @@ discard block |
||
1137 | 1289 | { |
1138 | 1290 | // build parameters |
1139 | 1291 | $parameters['q'] = (string) $q; |
1140 | - if($perPage != null) $parameters['per_page'] = (int) $perPage; |
|
1141 | - if($page != null) $parameters['page'] = (int) $page; |
|
1292 | + if($perPage != null) { |
|
1293 | + $parameters['per_page'] = (int) $perPage; |
|
1294 | + } |
|
1295 | + if($page != null) { |
|
1296 | + $parameters['page'] = (int) $page; |
|
1297 | + } |
|
1142 | 1298 | |
1143 | 1299 | // make the call |
1144 | 1300 | return (array) $this->doCall('users/search.json', $parameters, true); |
@@ -1188,10 +1344,18 @@ discard block |
||
1188 | 1344 | { |
1189 | 1345 | // build parameters |
1190 | 1346 | $parameters = array(); |
1191 | - if($id != null) $parameters['id'] = (string) $id; |
|
1192 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1193 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1194 | - if($cursor != null) $parameters['cursor'] = (int) $cursor; |
|
1347 | + if($id != null) { |
|
1348 | + $parameters['id'] = (string) $id; |
|
1349 | + } |
|
1350 | + if($userId != null) { |
|
1351 | + $parameters['user_id'] = (string) $userId; |
|
1352 | + } |
|
1353 | + if($screenName != null) { |
|
1354 | + $parameters['screen_name'] = (string) $screenName; |
|
1355 | + } |
|
1356 | + if($cursor != null) { |
|
1357 | + $parameters['cursor'] = (int) $cursor; |
|
1358 | + } |
|
1195 | 1359 | |
1196 | 1360 | // make the call |
1197 | 1361 | return (array) $this->doCall('statuses/friends.json', $parameters); |
@@ -1212,10 +1376,18 @@ discard block |
||
1212 | 1376 | { |
1213 | 1377 | // build parameters |
1214 | 1378 | $parameters = array(); |
1215 | - if($id != null) $parameters['id'] = (string) $id; |
|
1216 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1217 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1218 | - if($cursor != null) $parameters['cursor'] = (int) $cursor; |
|
1379 | + if($id != null) { |
|
1380 | + $parameters['id'] = (string) $id; |
|
1381 | + } |
|
1382 | + if($userId != null) { |
|
1383 | + $parameters['user_id'] = (string) $userId; |
|
1384 | + } |
|
1385 | + if($screenName != null) { |
|
1386 | + $parameters['screen_name'] = (string) $screenName; |
|
1387 | + } |
|
1388 | + if($cursor != null) { |
|
1389 | + $parameters['cursor'] = (int) $cursor; |
|
1390 | + } |
|
1219 | 1391 | |
1220 | 1392 | // make the call |
1221 | 1393 | return (array) $this->doCall('statuses/followers.json', $parameters); |
@@ -1246,7 +1418,9 @@ discard block |
||
1246 | 1418 | { |
1247 | 1419 | // build parameters |
1248 | 1420 | $parameters = array(); |
1249 | - if($exclude != null) $parameters['exclude'] = (string) $exclude; |
|
1421 | + if($exclude != null) { |
|
1422 | + $parameters['exclude'] = (string) $exclude; |
|
1423 | + } |
|
1250 | 1424 | |
1251 | 1425 | // make the call |
1252 | 1426 | return (array) $this->doCall('trends/current.json', $parameters); |
@@ -1264,8 +1438,12 @@ discard block |
||
1264 | 1438 | { |
1265 | 1439 | // build parameters |
1266 | 1440 | $parameters = array(); |
1267 | - if($exclude != null) $parameters['exclude'] = (string) $exclude; |
|
1268 | - if($date != null) $parameters['date'] = (string) $date; |
|
1441 | + if($exclude != null) { |
|
1442 | + $parameters['exclude'] = (string) $exclude; |
|
1443 | + } |
|
1444 | + if($date != null) { |
|
1445 | + $parameters['date'] = (string) $date; |
|
1446 | + } |
|
1269 | 1447 | |
1270 | 1448 | // make the call |
1271 | 1449 | return (array) $this->doCall('trends/daily.json', $parameters); |
@@ -1283,8 +1461,12 @@ discard block |
||
1283 | 1461 | { |
1284 | 1462 | // build parameters |
1285 | 1463 | $parameters = array(); |
1286 | - if($exclude != null) $parameters['exclude'] = (string) $exclude; |
|
1287 | - if($date != null) $parameters['date'] = (string) $date; |
|
1464 | + if($exclude != null) { |
|
1465 | + $parameters['exclude'] = (string) $exclude; |
|
1466 | + } |
|
1467 | + if($date != null) { |
|
1468 | + $parameters['date'] = (string) $date; |
|
1469 | + } |
|
1288 | 1470 | |
1289 | 1471 | // make the call |
1290 | 1472 | return (array) $this->doCall('trends/weekly.json', $parameters); |
@@ -1307,12 +1489,18 @@ discard block |
||
1307 | 1489 | $allowedModes = array('public', 'private'); |
1308 | 1490 | |
1309 | 1491 | // validate |
1310 | - if($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: '. implode($allowedModes) .'.'); |
|
1492 | + if($mode != null && !in_array($mode, $allowedModes)) { |
|
1493 | + throw new TwitterException('Invalid mode (), possible values are: '. implode($allowedModes) .'.'); |
|
1494 | + } |
|
1311 | 1495 | |
1312 | 1496 | // build parameters |
1313 | 1497 | $parameters['name'] = (string) $name; |
1314 | - if($mode != null) $parameters['mode'] = (string) $mode; |
|
1315 | - if($description != null) $parameters['description'] = (string) $description; |
|
1498 | + if($mode != null) { |
|
1499 | + $parameters['mode'] = (string) $mode; |
|
1500 | + } |
|
1501 | + if($description != null) { |
|
1502 | + $parameters['description'] = (string) $description; |
|
1503 | + } |
|
1316 | 1504 | |
1317 | 1505 | // make the call |
1318 | 1506 | return (array) $this->doCall((string) $user .'/lists.json', $parameters, true, 'POST'); |
@@ -1329,7 +1517,9 @@ discard block |
||
1329 | 1517 | public function userLists($user, $cursor = null) |
1330 | 1518 | { |
1331 | 1519 | $parameters = null; |
1332 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1520 | + if($cursor != null) { |
|
1521 | + $parameters['cursor'] = (string) $cursor; |
|
1522 | + } |
|
1333 | 1523 | |
1334 | 1524 | // make the call |
1335 | 1525 | return (array) $this->doCall((string) $user .'/lists.json', $parameters, true); |
@@ -1366,12 +1556,20 @@ discard block |
||
1366 | 1556 | $allowedModes = array('public', 'private'); |
1367 | 1557 | |
1368 | 1558 | // validate |
1369 | - if($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: '. implode($allowedModes) .'.'); |
|
1559 | + if($mode != null && !in_array($mode, $allowedModes)) { |
|
1560 | + throw new TwitterException('Invalid mode (), possible values are: '. implode($allowedModes) .'.'); |
|
1561 | + } |
|
1370 | 1562 | |
1371 | 1563 | // build parameters |
1372 | - if($name != null) $parameters['name'] = (string) $name; |
|
1373 | - if($mode != null) $parameters['mode'] = (string) $mode; |
|
1374 | - if($description != null) $parameters['description'] = (string) $description; |
|
1564 | + if($name != null) { |
|
1565 | + $parameters['name'] = (string) $name; |
|
1566 | + } |
|
1567 | + if($mode != null) { |
|
1568 | + $parameters['mode'] = (string) $mode; |
|
1569 | + } |
|
1570 | + if($description != null) { |
|
1571 | + $parameters['description'] = (string) $description; |
|
1572 | + } |
|
1375 | 1573 | |
1376 | 1574 | // make the call |
1377 | 1575 | return (array) $this->doCall((string) $user .'/lists/'. (string) $id .'.json', $parameters, true, 'POST'); |
@@ -1392,14 +1590,24 @@ discard block |
||
1392 | 1590 | public function userListsIdStatuses($user, $id, $sinceId = null, $maxId = null, $count = null, $page = null) |
1393 | 1591 | { |
1394 | 1592 | // validate |
1395 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1593 | + if($count != null && $count > 200) { |
|
1594 | + throw new TwitterException('Count may not be greater than 200.'); |
|
1595 | + } |
|
1396 | 1596 | |
1397 | 1597 | // build parameters |
1398 | 1598 | $parameters = array(); |
1399 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
1400 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
1401 | - if($count != null) $parameters['per_page'] = (int) $count; |
|
1402 | - if($page != null) $parameters['page'] = (int) $page; |
|
1599 | + if($sinceId != null) { |
|
1600 | + $parameters['since_id'] = (string) $sinceId; |
|
1601 | + } |
|
1602 | + if($maxId != null) { |
|
1603 | + $parameters['max_id'] = (string) $maxId; |
|
1604 | + } |
|
1605 | + if($count != null) { |
|
1606 | + $parameters['per_page'] = (int) $count; |
|
1607 | + } |
|
1608 | + if($page != null) { |
|
1609 | + $parameters['page'] = (int) $page; |
|
1610 | + } |
|
1403 | 1611 | |
1404 | 1612 | // make the call |
1405 | 1613 | return (array) $this->doCall((string) $user .'/lists/'. (string) $id .'/statuses.json', $parameters); |
@@ -1416,7 +1624,9 @@ discard block |
||
1416 | 1624 | public function userListsMemberships($user, $cursor = null) |
1417 | 1625 | { |
1418 | 1626 | $parameters = null; |
1419 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1627 | + if($cursor != null) { |
|
1628 | + $parameters['cursor'] = (string) $cursor; |
|
1629 | + } |
|
1420 | 1630 | |
1421 | 1631 | // make the call |
1422 | 1632 | return (array) $this->doCall((string) $user .'/lists/memberships.json', $parameters, true); |
@@ -1433,7 +1643,9 @@ discard block |
||
1433 | 1643 | public function userListsSubscriptions($user, $cursor = null) |
1434 | 1644 | { |
1435 | 1645 | $parameters = null; |
1436 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1646 | + if($cursor != null) { |
|
1647 | + $parameters['cursor'] = (string) $cursor; |
|
1648 | + } |
|
1437 | 1649 | |
1438 | 1650 | // make the call |
1439 | 1651 | return (array) $this->doCall((string) $user .'/lists/subscriptions.json', $parameters, true); |
@@ -1452,7 +1664,9 @@ discard block |
||
1452 | 1664 | public function userListMembers($user, $id, $cursor = null) |
1453 | 1665 | { |
1454 | 1666 | $parameters = null; |
1455 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1667 | + if($cursor != null) { |
|
1668 | + $parameters['cursor'] = (string) $cursor; |
|
1669 | + } |
|
1456 | 1670 | |
1457 | 1671 | // make the call |
1458 | 1672 | return (array) $this->doCall((string) $user .'/'. (string) $id .'/members.json', $parameters, true); |
@@ -1515,8 +1729,11 @@ discard block |
||
1515 | 1729 | // catch exceptions |
1516 | 1730 | catch(TwitterException $e) |
1517 | 1731 | { |
1518 | - if($e->getMessage() == 'The specified user is not a member of this list') return false; |
|
1519 | - else throw $e; |
|
1732 | + if($e->getMessage() == 'The specified user is not a member of this list') { |
|
1733 | + return false; |
|
1734 | + } else { |
|
1735 | + throw $e; |
|
1736 | + } |
|
1520 | 1737 | } |
1521 | 1738 | } |
1522 | 1739 | |
@@ -1533,7 +1750,9 @@ discard block |
||
1533 | 1750 | public function userListSubscribers($user, $id, $cursor = null) |
1534 | 1751 | { |
1535 | 1752 | $parameters = null; |
1536 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
1753 | + if($cursor != null) { |
|
1754 | + $parameters['cursor'] = (string) $cursor; |
|
1755 | + } |
|
1537 | 1756 | |
1538 | 1757 | // make the call |
1539 | 1758 | return (array) $this->doCall((string) $user .'/'. (string) $id .'/subscribers.json', $parameters, true); |
@@ -1590,8 +1809,11 @@ discard block |
||
1590 | 1809 | // catch exceptions |
1591 | 1810 | catch(TwitterException $e) |
1592 | 1811 | { |
1593 | - if($e->getMessage() == 'The specified user is not a subscriber of this list') return false; |
|
1594 | - else throw $e; |
|
1812 | + if($e->getMessage() == 'The specified user is not a subscriber of this list') { |
|
1813 | + return false; |
|
1814 | + } else { |
|
1815 | + throw $e; |
|
1816 | + } |
|
1595 | 1817 | } |
1596 | 1818 | |
1597 | 1819 | } |
@@ -1610,14 +1832,24 @@ discard block |
||
1610 | 1832 | public function directMessages($sinceId = null, $maxId = null, $count = null, $page = null) |
1611 | 1833 | { |
1612 | 1834 | // validate |
1613 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1835 | + if($count != null && $count > 200) { |
|
1836 | + throw new TwitterException('Count may not be greater than 200.'); |
|
1837 | + } |
|
1614 | 1838 | |
1615 | 1839 | // build parameters |
1616 | 1840 | $parameters = array(); |
1617 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
1618 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
1619 | - if($count != null) $parameters['count'] = (int) $count; |
|
1620 | - if($page != null) $parameters['page'] = (int) $page; |
|
1841 | + if($sinceId != null) { |
|
1842 | + $parameters['since_id'] = (string) $sinceId; |
|
1843 | + } |
|
1844 | + if($maxId != null) { |
|
1845 | + $parameters['max_id'] = (string) $maxId; |
|
1846 | + } |
|
1847 | + if($count != null) { |
|
1848 | + $parameters['count'] = (int) $count; |
|
1849 | + } |
|
1850 | + if($page != null) { |
|
1851 | + $parameters['page'] = (int) $page; |
|
1852 | + } |
|
1621 | 1853 | |
1622 | 1854 | // make the call |
1623 | 1855 | return (array) $this->doCall('direct_messages.json', $parameters, true); |
@@ -1636,14 +1868,24 @@ discard block |
||
1636 | 1868 | public function directMessagesSent($sinceId = null, $maxId = null, $count = null, $page = null) |
1637 | 1869 | { |
1638 | 1870 | // validate |
1639 | - if($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
1871 | + if($count != null && $count > 200) { |
|
1872 | + throw new TwitterException('Count may not be greater than 200.'); |
|
1873 | + } |
|
1640 | 1874 | |
1641 | 1875 | // build parameters |
1642 | 1876 | $parameters = array(); |
1643 | - if($sinceId != null) $parameters['since_id'] = (string) $sinceId; |
|
1644 | - if($maxId != null) $parameters['max_id'] = (string) $maxId; |
|
1645 | - if($count != null) $parameters['count'] = (int) $count; |
|
1646 | - if($page != null) $parameters['page'] = (int) $page; |
|
1877 | + if($sinceId != null) { |
|
1878 | + $parameters['since_id'] = (string) $sinceId; |
|
1879 | + } |
|
1880 | + if($maxId != null) { |
|
1881 | + $parameters['max_id'] = (string) $maxId; |
|
1882 | + } |
|
1883 | + if($count != null) { |
|
1884 | + $parameters['count'] = (int) $count; |
|
1885 | + } |
|
1886 | + if($page != null) { |
|
1887 | + $parameters['page'] = (int) $page; |
|
1888 | + } |
|
1647 | 1889 | |
1648 | 1890 | // make the call |
1649 | 1891 | return (array) $this->doCall('direct_messages/sent.json', $parameters, true); |
@@ -1663,13 +1905,21 @@ discard block |
||
1663 | 1905 | public function directMessagesNew($text, $id = null, $userId = null, $screenName = null) |
1664 | 1906 | { |
1665 | 1907 | // validate |
1666 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1908 | + if($id == '' && $userId == '' && $screenName == '') { |
|
1909 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1910 | + } |
|
1667 | 1911 | |
1668 | 1912 | // build parameters |
1669 | 1913 | $parameters['text'] = (string) $text; |
1670 | - if($id != null) $parameters['user'] = (string) $id; |
|
1671 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1672 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1914 | + if($id != null) { |
|
1915 | + $parameters['user'] = (string) $id; |
|
1916 | + } |
|
1917 | + if($userId != null) { |
|
1918 | + $parameters['user_id'] = (string) $userId; |
|
1919 | + } |
|
1920 | + if($screenName != null) { |
|
1921 | + $parameters['screen_name'] = (string) $screenName; |
|
1922 | + } |
|
1673 | 1923 | |
1674 | 1924 | // make the call |
1675 | 1925 | return (array) $this->doCall('direct_messages/new.json', $parameters, true, 'POST'); |
@@ -1707,12 +1957,20 @@ discard block |
||
1707 | 1957 | public function friendshipsCreate($id = null, $userId = null, $screenName = null, $follow = false) |
1708 | 1958 | { |
1709 | 1959 | // validate |
1710 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1960 | + if($id == '' && $userId == '' && $screenName == '') { |
|
1961 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1962 | + } |
|
1711 | 1963 | |
1712 | 1964 | // build parameters |
1713 | - if($id != null) $parameters['id'] = (string) $id; |
|
1714 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1715 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1965 | + if($id != null) { |
|
1966 | + $parameters['id'] = (string) $id; |
|
1967 | + } |
|
1968 | + if($userId != null) { |
|
1969 | + $parameters['user_id'] = (string) $userId; |
|
1970 | + } |
|
1971 | + if($screenName != null) { |
|
1972 | + $parameters['screen_name'] = (string) $screenName; |
|
1973 | + } |
|
1716 | 1974 | $parameters['follow'] = ($follow) ? 'true' : 'false'; |
1717 | 1975 | |
1718 | 1976 | // make the call |
@@ -1732,12 +1990,20 @@ discard block |
||
1732 | 1990 | public function friendshipsDestroy($id = null, $userId = null, $screenName = null) |
1733 | 1991 | { |
1734 | 1992 | // validate |
1735 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1993 | + if($id == '' && $userId == '' && $screenName == '') { |
|
1994 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
1995 | + } |
|
1736 | 1996 | |
1737 | 1997 | // build parameters |
1738 | - if($id != null) $parameters['id'] = (string) $id; |
|
1739 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1740 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1998 | + if($id != null) { |
|
1999 | + $parameters['id'] = (string) $id; |
|
2000 | + } |
|
2001 | + if($userId != null) { |
|
2002 | + $parameters['user_id'] = (string) $userId; |
|
2003 | + } |
|
2004 | + if($screenName != null) { |
|
2005 | + $parameters['screen_name'] = (string) $screenName; |
|
2006 | + } |
|
1741 | 2007 | |
1742 | 2008 | // make the call |
1743 | 2009 | return (array) $this->doCall('friendships/destroy.json', $parameters, true, 'POST'); |
@@ -1774,14 +2040,26 @@ discard block |
||
1774 | 2040 | public function friendshipsShow($sourceId = null, $sourceScreenName = null, $targetId = null, $targetScreenName = null) |
1775 | 2041 | { |
1776 | 2042 | // validate |
1777 | - if($sourceId == '' && $sourceScreenName == '') throw new TwitterException('Specify an sourceId or a sourceScreenName.'); |
|
1778 | - if($targetId == '' && $targetScreenName == '') throw new TwitterException('Specify an targetId or a targetScreenName.'); |
|
2043 | + if($sourceId == '' && $sourceScreenName == '') { |
|
2044 | + throw new TwitterException('Specify an sourceId or a sourceScreenName.'); |
|
2045 | + } |
|
2046 | + if($targetId == '' && $targetScreenName == '') { |
|
2047 | + throw new TwitterException('Specify an targetId or a targetScreenName.'); |
|
2048 | + } |
|
1779 | 2049 | |
1780 | 2050 | // build parameters |
1781 | - if($sourceId != null) $parameters['source_id'] = (string) $sourceId; |
|
1782 | - if($sourceScreenName != null) $parameters['source_screen_name'] = (string) $sourceScreenName; |
|
1783 | - if($targetId != null) $parameters['target_id'] = (string) $targetId; |
|
1784 | - if($targetScreenName != null) $parameters['target_screen_name'] = (string) $targetScreenName; |
|
2051 | + if($sourceId != null) { |
|
2052 | + $parameters['source_id'] = (string) $sourceId; |
|
2053 | + } |
|
2054 | + if($sourceScreenName != null) { |
|
2055 | + $parameters['source_screen_name'] = (string) $sourceScreenName; |
|
2056 | + } |
|
2057 | + if($targetId != null) { |
|
2058 | + $parameters['target_id'] = (string) $targetId; |
|
2059 | + } |
|
2060 | + if($targetScreenName != null) { |
|
2061 | + $parameters['target_screen_name'] = (string) $targetScreenName; |
|
2062 | + } |
|
1785 | 2063 | |
1786 | 2064 | // make the call |
1787 | 2065 | return (array) $this->doCall('friendships/show.json', $parameters); |
@@ -1797,7 +2075,9 @@ discard block |
||
1797 | 2075 | public function friendshipsIncoming($cursor = null) |
1798 | 2076 | { |
1799 | 2077 | $parameters = null; |
1800 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
2078 | + if($cursor != null) { |
|
2079 | + $parameters['cursor'] = (string) $cursor; |
|
2080 | + } |
|
1801 | 2081 | |
1802 | 2082 | // make the call |
1803 | 2083 | return (array) $this->doCall('friendships/incoming.json', $parameters, true); |
@@ -1813,7 +2093,9 @@ discard block |
||
1813 | 2093 | public function friendshipsOutgoing($cursor = null) |
1814 | 2094 | { |
1815 | 2095 | $parameters = null; |
1816 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
2096 | + if($cursor != null) { |
|
2097 | + $parameters['cursor'] = (string) $cursor; |
|
2098 | + } |
|
1817 | 2099 | |
1818 | 2100 | // make the call |
1819 | 2101 | return (array) $this->doCall('friendships/outgoing.json', $parameters, true); |
@@ -1833,13 +2115,23 @@ discard block |
||
1833 | 2115 | public function friendsIds($id = null, $userId = null, $screenName = null, $cursor = null) |
1834 | 2116 | { |
1835 | 2117 | // validate |
1836 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2118 | + if($id == '' && $userId == '' && $screenName == '') { |
|
2119 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2120 | + } |
|
1837 | 2121 | |
1838 | 2122 | // build parameters |
1839 | - if($id != null) $parameters['id'] = (string) $id; |
|
1840 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1841 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1842 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
2123 | + if($id != null) { |
|
2124 | + $parameters['id'] = (string) $id; |
|
2125 | + } |
|
2126 | + if($userId != null) { |
|
2127 | + $parameters['user_id'] = (string) $userId; |
|
2128 | + } |
|
2129 | + if($screenName != null) { |
|
2130 | + $parameters['screen_name'] = (string) $screenName; |
|
2131 | + } |
|
2132 | + if($cursor != null) { |
|
2133 | + $parameters['cursor'] = (string) $cursor; |
|
2134 | + } |
|
1843 | 2135 | |
1844 | 2136 | // make the call |
1845 | 2137 | return (array) $this->doCall('friends/ids.json', $parameters); |
@@ -1858,13 +2150,23 @@ discard block |
||
1858 | 2150 | public function followersIds($id = null, $userId = null, $screenName = null, $cursor = null) |
1859 | 2151 | { |
1860 | 2152 | // validate |
1861 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2153 | + if($id == '' && $userId == '' && $screenName == '') { |
|
2154 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2155 | + } |
|
1862 | 2156 | |
1863 | 2157 | // build parameters |
1864 | - if($id != null) $parameters['id'] = (string) $id; |
|
1865 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
1866 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
1867 | - if($cursor != null) $parameters['cursor'] = (string) $cursor; |
|
2158 | + if($id != null) { |
|
2159 | + $parameters['id'] = (string) $id; |
|
2160 | + } |
|
2161 | + if($userId != null) { |
|
2162 | + $parameters['user_id'] = (string) $userId; |
|
2163 | + } |
|
2164 | + if($screenName != null) { |
|
2165 | + $parameters['screen_name'] = (string) $screenName; |
|
2166 | + } |
|
2167 | + if($cursor != null) { |
|
2168 | + $parameters['cursor'] = (string) $cursor; |
|
2169 | + } |
|
1868 | 2170 | |
1869 | 2171 | // make the call |
1870 | 2172 | return (array) $this->doCall('followers/ids.json', $parameters); |
@@ -1911,8 +2213,11 @@ discard block |
||
1911 | 2213 | // catch exceptions |
1912 | 2214 | catch(TwitterException $e) |
1913 | 2215 | { |
1914 | - if($e->getMessage() == 'Logged out.') return true; |
|
1915 | - else throw $e; |
|
2216 | + if($e->getMessage() == 'Logged out.') { |
|
2217 | + return true; |
|
2218 | + } else { |
|
2219 | + throw $e; |
|
2220 | + } |
|
1916 | 2221 | } |
1917 | 2222 | } |
1918 | 2223 | |
@@ -1947,14 +2252,26 @@ discard block |
||
1947 | 2252 | public function accountUpdateProfileColors($profileBackgroundColor = null, $profileTextColor = null, $profileLinkColor = null, $profileSidebarFillColor = null, $profileSidebarBorderColor = null) |
1948 | 2253 | { |
1949 | 2254 | // validate |
1950 | - if($profileBackgroundColor == '' && $profileTextColor == '' && $profileLinkColor == '' && $profileSidebarFillColor == '' && $profileSidebarBorderColor == '') throw new TwitterException('Specify a profileBackgroundColor, profileTextColor, profileLinkColor, profileSidebarFillColor or a profileSidebarBorderColor.'); |
|
2255 | + if($profileBackgroundColor == '' && $profileTextColor == '' && $profileLinkColor == '' && $profileSidebarFillColor == '' && $profileSidebarBorderColor == '') { |
|
2256 | + throw new TwitterException('Specify a profileBackgroundColor, profileTextColor, profileLinkColor, profileSidebarFillColor or a profileSidebarBorderColor.'); |
|
2257 | + } |
|
1951 | 2258 | |
1952 | 2259 | // build parameters |
1953 | - if($profileBackgroundColor != null) $parameters['profile_background_color'] = (string) $profileBackgroundColor; |
|
1954 | - if($profileTextColor != null) $parameters['profile_text_color'] = (string) $profileTextColor; |
|
1955 | - if($profileLinkColor != null) $parameters['profile_link_color'] = (string) $profileLinkColor; |
|
1956 | - if($profileSidebarFillColor != null) $parameters['profile_sidebar_fill_color'] = (string) $profileSidebarFillColor; |
|
1957 | - if($profileSidebarBorderColor != null) $parameters['profile_sidebar_border_color'] = (string) $profileSidebarBorderColor; |
|
2260 | + if($profileBackgroundColor != null) { |
|
2261 | + $parameters['profile_background_color'] = (string) $profileBackgroundColor; |
|
2262 | + } |
|
2263 | + if($profileTextColor != null) { |
|
2264 | + $parameters['profile_text_color'] = (string) $profileTextColor; |
|
2265 | + } |
|
2266 | + if($profileLinkColor != null) { |
|
2267 | + $parameters['profile_link_color'] = (string) $profileLinkColor; |
|
2268 | + } |
|
2269 | + if($profileSidebarFillColor != null) { |
|
2270 | + $parameters['profile_sidebar_fill_color'] = (string) $profileSidebarFillColor; |
|
2271 | + } |
|
2272 | + if($profileSidebarBorderColor != null) { |
|
2273 | + $parameters['profile_sidebar_border_color'] = (string) $profileSidebarBorderColor; |
|
2274 | + } |
|
1958 | 2275 | |
1959 | 2276 | // make the call |
1960 | 2277 | return (array) $this->doCall('account/update_profile_colors.json', $parameters, true, 'POST'); |
@@ -1972,7 +2289,9 @@ discard block |
||
1972 | 2289 | throw new TwitterException('Not implemented'); |
1973 | 2290 | |
1974 | 2291 | // validate |
1975 | - if(!file_exists($image)) throw new TwitterException('Image ('. $image .') doesn\'t exists.'); |
|
2292 | + if(!file_exists($image)) { |
|
2293 | + throw new TwitterException('Image ('. $image .') doesn\'t exists.'); |
|
2294 | + } |
|
1976 | 2295 | |
1977 | 2296 | // make the call |
1978 | 2297 | return (array) $this->doCall('account/update_profile_image.json', null, true, 'POST', $image); |
@@ -1991,10 +2310,14 @@ discard block |
||
1991 | 2310 | throw new TwitterException('Not implemented'); |
1992 | 2311 | |
1993 | 2312 | // validate |
1994 | - if(!file_exists($image)) throw new TwitterException('Image ('. $image .') doesn\'t exists.'); |
|
2313 | + if(!file_exists($image)) { |
|
2314 | + throw new TwitterException('Image ('. $image .') doesn\'t exists.'); |
|
2315 | + } |
|
1995 | 2316 | |
1996 | 2317 | // build parameters |
1997 | - if($tile) $parameters['tile'] = 'true'; |
|
2318 | + if($tile) { |
|
2319 | + $parameters['tile'] = 'true'; |
|
2320 | + } |
|
1998 | 2321 | |
1999 | 2322 | // make the call |
2000 | 2323 | return (array) $this->doCall('account/update_profile_background_image.json', $parameters, true, 'POST', $image); |
@@ -2014,10 +2337,18 @@ discard block |
||
2014 | 2337 | { |
2015 | 2338 | // build parameters |
2016 | 2339 | $parameters = null; |
2017 | - if($name != null) $parameters['name'] = (string) $name; |
|
2018 | - if($url != null) $parameters['url'] = (string) $url; |
|
2019 | - if($location != null) $parameters['location'] = (string) $location; |
|
2020 | - if($description != null) $parameters['description'] = (string) $description; |
|
2340 | + if($name != null) { |
|
2341 | + $parameters['name'] = (string) $name; |
|
2342 | + } |
|
2343 | + if($url != null) { |
|
2344 | + $parameters['url'] = (string) $url; |
|
2345 | + } |
|
2346 | + if($location != null) { |
|
2347 | + $parameters['location'] = (string) $location; |
|
2348 | + } |
|
2349 | + if($description != null) { |
|
2350 | + $parameters['description'] = (string) $description; |
|
2351 | + } |
|
2021 | 2352 | |
2022 | 2353 | // make the call |
2023 | 2354 | return (array) $this->doCall('account/update_profile.json', $parameters, true, 'POST'); |
@@ -2036,8 +2367,12 @@ discard block |
||
2036 | 2367 | { |
2037 | 2368 | // build parameters |
2038 | 2369 | $parameters = null; |
2039 | - if($id != null) $parameters['id'] = (string) $id; |
|
2040 | - if($page != null) $parameters['page'] = (int) $page; |
|
2370 | + if($id != null) { |
|
2371 | + $parameters['id'] = (string) $id; |
|
2372 | + } |
|
2373 | + if($page != null) { |
|
2374 | + $parameters['page'] = (int) $page; |
|
2375 | + } |
|
2041 | 2376 | |
2042 | 2377 | // make the call |
2043 | 2378 | return (array) $this->doCall('favorites.json', $parameters, true); |
@@ -2082,12 +2417,20 @@ discard block |
||
2082 | 2417 | public function notificationsFollow($id = null, $userId = null, $screenName = null) |
2083 | 2418 | { |
2084 | 2419 | // validate |
2085 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2420 | + if($id == '' && $userId == '' && $screenName == '') { |
|
2421 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2422 | + } |
|
2086 | 2423 | |
2087 | 2424 | // build parameters |
2088 | - if($id != null) $parameters['id'] = (string) $id; |
|
2089 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
2090 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2425 | + if($id != null) { |
|
2426 | + $parameters['id'] = (string) $id; |
|
2427 | + } |
|
2428 | + if($userId != null) { |
|
2429 | + $parameters['user_id'] = (string) $userId; |
|
2430 | + } |
|
2431 | + if($screenName != null) { |
|
2432 | + $parameters['screen_name'] = (string) $screenName; |
|
2433 | + } |
|
2091 | 2434 | |
2092 | 2435 | // make the call |
2093 | 2436 | return (array) $this->doCall('notifications/follow.json', $parameters, true, 'POST'); |
@@ -2105,12 +2448,20 @@ discard block |
||
2105 | 2448 | public function notificationsLeave($id = null, $userId = null, $screenName = null) |
2106 | 2449 | { |
2107 | 2450 | // validate |
2108 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2451 | + if($id == '' && $userId == '' && $screenName == '') { |
|
2452 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2453 | + } |
|
2109 | 2454 | |
2110 | 2455 | // build parameters |
2111 | - if($id != null) $parameters['id'] = (string) $id; |
|
2112 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
2113 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2456 | + if($id != null) { |
|
2457 | + $parameters['id'] = (string) $id; |
|
2458 | + } |
|
2459 | + if($userId != null) { |
|
2460 | + $parameters['user_id'] = (string) $userId; |
|
2461 | + } |
|
2462 | + if($screenName != null) { |
|
2463 | + $parameters['screen_name'] = (string) $screenName; |
|
2464 | + } |
|
2114 | 2465 | |
2115 | 2466 | // make the call |
2116 | 2467 | return (array) $this->doCall('notifications/leave.json', $parameters, true, 'POST'); |
@@ -2129,12 +2480,20 @@ discard block |
||
2129 | 2480 | public function blocksCreate($id = null, $userId = null, $screenName = null) |
2130 | 2481 | { |
2131 | 2482 | // validate |
2132 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2483 | + if($id == '' && $userId == '' && $screenName == '') { |
|
2484 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2485 | + } |
|
2133 | 2486 | |
2134 | 2487 | // build parameters |
2135 | - if($id != null) $parameters['id'] = (string) $id; |
|
2136 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
2137 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2488 | + if($id != null) { |
|
2489 | + $parameters['id'] = (string) $id; |
|
2490 | + } |
|
2491 | + if($userId != null) { |
|
2492 | + $parameters['user_id'] = (string) $userId; |
|
2493 | + } |
|
2494 | + if($screenName != null) { |
|
2495 | + $parameters['screen_name'] = (string) $screenName; |
|
2496 | + } |
|
2138 | 2497 | |
2139 | 2498 | // make the call |
2140 | 2499 | return (array) $this->doCall('blocks/create.json', $parameters, true, 'POST'); |
@@ -2152,12 +2511,20 @@ discard block |
||
2152 | 2511 | public function blocksDestroy($id = null, $userId = null, $screenName = null) |
2153 | 2512 | { |
2154 | 2513 | // validate |
2155 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2514 | + if($id == '' && $userId == '' && $screenName == '') { |
|
2515 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2516 | + } |
|
2156 | 2517 | |
2157 | 2518 | // build parameters |
2158 | - if($id != null) $parameters['id'] = (string) $id; |
|
2159 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
2160 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2519 | + if($id != null) { |
|
2520 | + $parameters['id'] = (string) $id; |
|
2521 | + } |
|
2522 | + if($userId != null) { |
|
2523 | + $parameters['user_id'] = (string) $userId; |
|
2524 | + } |
|
2525 | + if($screenName != null) { |
|
2526 | + $parameters['screen_name'] = (string) $screenName; |
|
2527 | + } |
|
2161 | 2528 | |
2162 | 2529 | // make the call |
2163 | 2530 | return (array) $this->doCall('blocks/destroy.json', $parameters, true, 'POST'); |
@@ -2175,12 +2542,20 @@ discard block |
||
2175 | 2542 | public function blocksExists($id = null, $userId = null, $screenName = null) |
2176 | 2543 | { |
2177 | 2544 | // validate |
2178 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2545 | + if($id == '' && $userId == '' && $screenName == '') { |
|
2546 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2547 | + } |
|
2179 | 2548 | |
2180 | 2549 | // build parameters |
2181 | - if($id != null) $parameters['id'] = (string) $id; |
|
2182 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
2183 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2550 | + if($id != null) { |
|
2551 | + $parameters['id'] = (string) $id; |
|
2552 | + } |
|
2553 | + if($userId != null) { |
|
2554 | + $parameters['user_id'] = (string) $userId; |
|
2555 | + } |
|
2556 | + if($screenName != null) { |
|
2557 | + $parameters['screen_name'] = (string) $screenName; |
|
2558 | + } |
|
2184 | 2559 | |
2185 | 2560 | try |
2186 | 2561 | { |
@@ -2190,8 +2565,11 @@ discard block |
||
2190 | 2565 | // catch exceptions |
2191 | 2566 | catch(TwitterException $e) |
2192 | 2567 | { |
2193 | - if($e->getMessage() == 'You are not blocking this user.') return false; |
|
2194 | - else throw $e; |
|
2568 | + if($e->getMessage() == 'You are not blocking this user.') { |
|
2569 | + return false; |
|
2570 | + } else { |
|
2571 | + throw $e; |
|
2572 | + } |
|
2195 | 2573 | } |
2196 | 2574 | } |
2197 | 2575 | |
@@ -2206,7 +2584,9 @@ discard block |
||
2206 | 2584 | { |
2207 | 2585 | // build parameters |
2208 | 2586 | $parameters = null; |
2209 | - if($page != null) $parameters['page'] = (int) $page; |
|
2587 | + if($page != null) { |
|
2588 | + $parameters['page'] = (int) $page; |
|
2589 | + } |
|
2210 | 2590 | |
2211 | 2591 | // make the call |
2212 | 2592 | return (array) $this->doCall('blocks/blocking.json', $parameters, true); |
@@ -2237,12 +2617,20 @@ discard block |
||
2237 | 2617 | public function reportSpam($id = null, $userId = null, $screenName = null) |
2238 | 2618 | { |
2239 | 2619 | // validate |
2240 | - if($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2620 | + if($id == '' && $userId == '' && $screenName == '') { |
|
2621 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
2622 | + } |
|
2241 | 2623 | |
2242 | 2624 | // build parameters |
2243 | - if($id != null) $parameters['id'] = (string) $id; |
|
2244 | - if($userId != null) $parameters['user_id'] = (string) $userId; |
|
2245 | - if($screenName != null) $parameters['screen_name'] = (string) $screenName; |
|
2625 | + if($id != null) { |
|
2626 | + $parameters['id'] = (string) $id; |
|
2627 | + } |
|
2628 | + if($userId != null) { |
|
2629 | + $parameters['user_id'] = (string) $userId; |
|
2630 | + } |
|
2631 | + if($screenName != null) { |
|
2632 | + $parameters['screen_name'] = (string) $screenName; |
|
2633 | + } |
|
2246 | 2634 | |
2247 | 2635 | // make the call |
2248 | 2636 | return (array) $this->doCall('report_spam.json', $parameters, true, 'POST'); |
@@ -2321,17 +2709,25 @@ discard block |
||
2321 | 2709 | $parameters = array(); |
2322 | 2710 | |
2323 | 2711 | // set callback |
2324 | - if($callbackURL != null) $parameters['oauth_callback'] = (string) $callbackURL; |
|
2712 | + if($callbackURL != null) { |
|
2713 | + $parameters['oauth_callback'] = (string) $callbackURL; |
|
2714 | + } |
|
2325 | 2715 | |
2326 | 2716 | // make the call |
2327 | 2717 | $response = $this->doOAuthCall('request_token', $parameters); |
2328 | 2718 | |
2329 | 2719 | // validate |
2330 | - if(!isset($response['oauth_token'], $response['oauth_token_secret'])) throw new TwitterException(implode(', ', array_keys($response))); |
|
2720 | + if(!isset($response['oauth_token'], $response['oauth_token_secret'])) { |
|
2721 | + throw new TwitterException(implode(', ', array_keys($response))); |
|
2722 | + } |
|
2331 | 2723 | |
2332 | 2724 | // set some properties |
2333 | - if(isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']); |
|
2334 | - if(isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']); |
|
2725 | + if(isset($response['oauth_token'])) { |
|
2726 | + $this->setOAuthToken($response['oauth_token']); |
|
2727 | + } |
|
2728 | + if(isset($response['oauth_token_secret'])) { |
|
2729 | + $this->setOAuthTokenSecret($response['oauth_token_secret']); |
|
2730 | + } |
|
2335 | 2731 | |
2336 | 2732 | // return |
2337 | 2733 | return $response; |
@@ -2357,8 +2753,12 @@ discard block |
||
2357 | 2753 | $response = $this->doOAuthCall('access_token', $parameters); |
2358 | 2754 | |
2359 | 2755 | // set some properties |
2360 | - if(isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']); |
|
2361 | - if(isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']); |
|
2756 | + if(isset($response['oauth_token'])) { |
|
2757 | + $this->setOAuthToken($response['oauth_token']); |
|
2758 | + } |
|
2759 | + if(isset($response['oauth_token_secret'])) { |
|
2760 | + $this->setOAuthTokenSecret($response['oauth_token_secret']); |
|
2761 | + } |
|
2362 | 2762 | |
2363 | 2763 | // return |
2364 | 2764 | return $response; |
@@ -2403,8 +2803,12 @@ discard block |
||
2403 | 2803 | { |
2404 | 2804 | // build parameters |
2405 | 2805 | $parameters = null; |
2406 | - if($lat != null) $parameters['lat_for_trends'] = (float) $lat; |
|
2407 | - if($long != null) $parameters['long_for_trends'] = (float) $long; |
|
2806 | + if($lat != null) { |
|
2807 | + $parameters['lat_for_trends'] = (float) $lat; |
|
2808 | + } |
|
2809 | + if($long != null) { |
|
2810 | + $parameters['long_for_trends'] = (float) $long; |
|
2811 | + } |
|
2408 | 2812 | |
2409 | 2813 | // make the call |
2410 | 2814 | return (array) $this->doCall('trends/available.json', $parameters); |
@@ -2446,9 +2850,15 @@ discard block |
||
2446 | 2850 | // build parameters |
2447 | 2851 | $parameters['lat'] = (float) $lat; |
2448 | 2852 | $parameters['long'] = (float) $long; |
2449 | - if($accuracy != null) $parameters['accuracy'] = (string) $accuracy; |
|
2450 | - if($granularity != null) $parameters['granularity'] = (string) $granularity; |
|
2451 | - if($maxResults != null) $parameters['max_results'] = (int) $maxResults; |
|
2853 | + if($accuracy != null) { |
|
2854 | + $parameters['accuracy'] = (string) $accuracy; |
|
2855 | + } |
|
2856 | + if($granularity != null) { |
|
2857 | + $parameters['granularity'] = (string) $granularity; |
|
2858 | + } |
|
2859 | + if($maxResults != null) { |
|
2860 | + $parameters['max_results'] = (int) $maxResults; |
|
2861 | + } |
|
2452 | 2862 | |
2453 | 2863 | // make the call |
2454 | 2864 | return (array) $this->doCall('geo/reverse_geocode.json', $parameters); |
@@ -2466,7 +2876,9 @@ discard block |
||
2466 | 2876 | { |
2467 | 2877 | // build parameters |
2468 | 2878 | $parameters = null; |
2469 | - if($placeId != null) $parameters['place_id'] = (string) $placeId; |
|
2879 | + if($placeId != null) { |
|
2880 | + $parameters['place_id'] = (string) $placeId; |
|
2881 | + } |
|
2470 | 2882 | |
2471 | 2883 | // make the call |
2472 | 2884 | return (array) $this->doCall('geo/id/'. (string) $id .'.json', $parameters); |