@@ -64,9 +64,11 @@ |
||
| 64 | 64 | if ($link_handler->mysql_major_version() >= 4): |
| 65 | 65 | $sql = " DELETE FROM {$link_handler->table}" . ' WHERE ' . " tag_modid = {$mid}" . ' AND ' . ' ( tag_itemid NOT IN ' . " ( SELECT DISTINCT {$item_handler_keyName} " . " FROM {$item_handler_table} " . " WHERE $where" . ' ) ' |
| 66 | 66 | . ' )'; |
| 67 | - else: |
|
| 67 | + else { |
|
| 68 | + : |
|
| 68 | 69 | $sql = " DELETE {$link_handler->table} FROM {$link_handler->table}" . " LEFT JOIN {$item_handler_table} AS aa ON {$link_handler->table}.tag_itemid = aa.{$item_handler_keyName} " . ' WHERE ' . " tag_modid = {$mid}" . ' AND ' . " ( aa.{$item_handler_keyName} IS NULL" |
| 69 | 70 | . " OR $where1" . ' )'; |
| 71 | + } |
|
| 70 | 72 | endif; |
| 71 | 73 | if (!$link_handler->db->queryF($sql)) { |
| 72 | 74 | trigger_error($link_handler->db->error()); |
@@ -48,7 +48,9 @@ discard block |
||
| 48 | 48 | $this->error = 'Socket error: Could not send all data.'; |
| 49 | 49 | return false; |
| 50 | 50 | } |
| 51 | - if ($this->debug) echo "Sent:\n{$to_send}\n\n"; |
|
| 51 | + if ($this->debug) { |
|
| 52 | + echo "Sent:\n{$to_send}\n\n"; |
|
| 53 | + } |
|
| 52 | 54 | $response = ''; |
| 53 | 55 | while (!feof($fp)) { |
| 54 | 56 | $buf = fread($fp, 1024); |
@@ -58,7 +60,9 @@ discard block |
||
| 58 | 60 | } |
| 59 | 61 | $response .= $buf; |
| 60 | 62 | } |
| 61 | - if ($this->debug) echo "Received:\n{$response}"; |
|
| 63 | + if ($this->debug) { |
|
| 64 | + echo "Received:\n{$response}"; |
|
| 65 | + } |
|
| 62 | 66 | $was_error = preg_match('#' . preg_quote('<error>') . '(.+)' . preg_quote('</error>') . '#i', $response, $matches); |
| 63 | 67 | if ($was_error) { |
| 64 | 68 | $this->error = "Twitter error: {$matches[1]}"; |
@@ -125,7 +125,9 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public function __destruct() |
| 127 | 127 | { |
| 128 | - if ($this->curl != null) curl_close($this->curl); |
|
| 128 | + if ($this->curl != null) { |
|
| 129 | + curl_close($this->curl); |
|
| 130 | + } |
|
| 129 | 131 | } |
| 130 | 132 | |
| 131 | 133 | /** |
@@ -137,7 +139,9 @@ discard block |
||
| 137 | 139 | private function buildQuery(array $parameters) |
| 138 | 140 | { |
| 139 | 141 | // no parameters? |
| 140 | - if (empty($parameters)) return ''; |
|
| 142 | + if (empty($parameters)) { |
|
| 143 | + return ''; |
|
| 144 | + } |
|
| 141 | 145 | |
| 142 | 146 | // encode the keys |
| 143 | 147 | $keys = self::urlencode_rfc3986(array_keys($parameters)); |
@@ -154,11 +158,15 @@ discard block |
||
| 154 | 158 | // loop parameters |
| 155 | 159 | foreach ($parameters as $key => $value) { |
| 156 | 160 | // sort by value |
| 157 | - if (is_array($value)) $parameters[$key] = natsort($value); |
|
| 161 | + if (is_array($value)) { |
|
| 162 | + $parameters[$key] = natsort($value); |
|
| 163 | + } |
|
| 158 | 164 | } |
| 159 | 165 | |
| 160 | 166 | // process parameters |
| 161 | - foreach ($parameters as $key => $value) $chunks[] = $key . '=' . str_replace('%25', '%', $value); |
|
| 167 | + foreach ($parameters as $key => $value) { |
|
| 168 | + $chunks[] = $key . '=' . str_replace('%25', '%', $value); |
|
| 169 | + } |
|
| 162 | 170 | |
| 163 | 171 | // return |
| 164 | 172 | return implode('&', $chunks); |
@@ -195,7 +203,9 @@ discard block |
||
| 195 | 203 | // loop parameters |
| 196 | 204 | foreach ($parameters as $key => $value) { |
| 197 | 205 | // sort by value |
| 198 | - if (is_array($value)) $parameters[$key] = natsort($value); |
|
| 206 | + if (is_array($value)) { |
|
| 207 | + $parameters[$key] = natsort($value); |
|
| 208 | + } |
|
| 199 | 209 | } |
| 200 | 210 | |
| 201 | 211 | // process queries |
@@ -233,7 +243,9 @@ discard block |
||
| 233 | 243 | $chunks = array(); |
| 234 | 244 | |
| 235 | 245 | // process queries |
| 236 | - foreach ($parameters as $key => $value) $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) . '="' . self::urlencode_rfc3986($value) . '"'); |
|
| 246 | + foreach ($parameters as $key => $value) { |
|
| 247 | + $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) . '="' . self::urlencode_rfc3986($value) . '"'); |
|
| 248 | + } |
|
| 237 | 249 | |
| 238 | 250 | // build return |
| 239 | 251 | $return = 'Authorization: OAuth realm="' . $parts['scheme'] . '://' . $parts['host'] . $parts['path'] . '", '; |
@@ -288,7 +300,9 @@ discard block |
||
| 288 | 300 | $options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters); |
| 289 | 301 | |
| 290 | 302 | // init |
| 291 | - if ($this->curl == null) $this->curl = curl_init(); |
|
| 303 | + if ($this->curl == null) { |
|
| 304 | + $this->curl = curl_init(); |
|
| 305 | + } |
|
| 292 | 306 | |
| 293 | 307 | // set options |
| 294 | 308 | curl_setopt_array($this->curl, $options); |
@@ -302,7 +316,9 @@ discard block |
||
| 302 | 316 | $errorMessage = curl_error($this->curl); |
| 303 | 317 | |
| 304 | 318 | // error? |
| 305 | - if ($errorNumber != '') throw new TwitterException($errorMessage, $errorNumber); |
|
| 319 | + if ($errorNumber != '') { |
|
| 320 | + throw new TwitterException($errorMessage, $errorNumber); |
|
| 321 | + } |
|
| 306 | 322 | |
| 307 | 323 | // init var |
| 308 | 324 | $return = array(); |
@@ -343,7 +359,9 @@ discard block |
||
| 343 | 359 | $expectJSON = (bool)$expectJSON; |
| 344 | 360 | |
| 345 | 361 | // validate method |
| 346 | - if (!in_array($method, $allowedMethods)) throw new TwitterException('Unknown method (' . $method . '). Allowed methods are: ' . implode(', ', $allowedMethods)); |
|
| 362 | + if (!in_array($method, $allowedMethods)) { |
|
| 363 | + throw new TwitterException('Unknown method (' . $method . '). Allowed methods are: ' . implode(', ', $allowedMethods)); |
|
| 364 | + } |
|
| 347 | 365 | |
| 348 | 366 | // append default parameters |
| 349 | 367 | $oauth['oauth_consumer_key'] = $this->getConsumerKey(); |
@@ -355,7 +373,9 @@ discard block |
||
| 355 | 373 | |
| 356 | 374 | // set data |
| 357 | 375 | $data = $oauth; |
| 358 | - if (!empty($parameters)) $data = array_merge($data, $parameters); |
|
| 376 | + if (!empty($parameters)) { |
|
| 377 | + $data = array_merge($data, $parameters); |
|
| 378 | + } |
|
| 359 | 379 | |
| 360 | 380 | // calculate the base string |
| 361 | 381 | $base = $this->calculateBaseString(self::API_URL . '/' . $url, $method, $data); |
@@ -380,8 +400,11 @@ discard block |
||
| 380 | 400 | $mimeType = 'application/octet-stream'; |
| 381 | 401 | if ($fileInfo['extension'] === 'jpg' || $fileInfo['extension'] === 'jpeg') { |
| 382 | 402 | $mimeType = 'image/jpeg'; |
| 383 | - } elseif ($fileInfo['extension'] === 'gif') $mimeType = 'image/gif'; |
|
| 384 | - elseif ($fileInfo['extension'] === 'png') $mimeType = 'image/png'; |
|
| 403 | + } elseif ($fileInfo['extension'] === 'gif') { |
|
| 404 | + $mimeType = 'image/gif'; |
|
| 405 | + } elseif ($fileInfo['extension'] === 'png') { |
|
| 406 | + $mimeType = 'image/png'; |
|
| 407 | + } |
|
| 385 | 408 | |
| 386 | 409 | // init var |
| 387 | 410 | $content = '--' . $boundary . "\r\n"; |
@@ -396,13 +419,17 @@ discard block |
||
| 396 | 419 | // set content |
| 397 | 420 | $options[CURLOPT_POSTFIELDS] = $content; |
| 398 | 421 | } // no file |
| 399 | - else $options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters); |
|
| 422 | + else { |
|
| 423 | + $options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters); |
|
| 424 | + } |
|
| 400 | 425 | |
| 401 | 426 | // enable post |
| 402 | 427 | $options[CURLOPT_POST] = 1; |
| 403 | 428 | } else { |
| 404 | 429 | // add the parameters into the querystring |
| 405 | - if (!empty($parameters)) $url .= '?' . $this->buildQuery($parameters); |
|
| 430 | + if (!empty($parameters)) { |
|
| 431 | + $url .= '?' . $this->buildQuery($parameters); |
|
| 432 | + } |
|
| 406 | 433 | } |
| 407 | 434 | |
| 408 | 435 | // set options |
@@ -418,7 +445,9 @@ discard block |
||
| 418 | 445 | $options[CURLOPT_HTTPHEADER] = $headers; |
| 419 | 446 | |
| 420 | 447 | // init |
| 421 | - if ($this->curl == null) $this->curl = curl_init(); |
|
| 448 | + if ($this->curl == null) { |
|
| 449 | + $this->curl = curl_init(); |
|
| 450 | + } |
|
| 422 | 451 | |
| 423 | 452 | // set options |
| 424 | 453 | curl_setopt_array($this->curl, $options); |
@@ -432,7 +461,9 @@ discard block |
||
| 432 | 461 | $errorMessage = curl_error($this->curl); |
| 433 | 462 | |
| 434 | 463 | // we don't expext JSON, return the response |
| 435 | - if (!$expectJSON) return $response; |
|
| 464 | + if (!$expectJSON) { |
|
| 465 | + return $response; |
|
| 466 | + } |
|
| 436 | 467 | |
| 437 | 468 | // replace ids with their string values, added because of some PHP-version can't handle these large values |
| 438 | 469 | $response = preg_replace('/id":(\d+)/', 'id":"\1"', $response); |
@@ -487,7 +518,9 @@ discard block |
||
| 487 | 518 | // throw exception |
| 488 | 519 | if (isset($json['errors'][0]['message'])) { |
| 489 | 520 | throw new TwitterException($json['errors'][0]['message']); |
| 490 | - } else throw new TwitterException('Invalid response.'); |
|
| 521 | + } else { |
|
| 522 | + throw new TwitterException('Invalid response.'); |
|
| 523 | + } |
|
| 491 | 524 | } |
| 492 | 525 | |
| 493 | 526 | // any error |
@@ -689,7 +722,9 @@ discard block |
||
| 689 | 722 | |
| 690 | 723 | // build parameters |
| 691 | 724 | $parameters = array(); |
| 692 | - if ($skipUser) $parameters['skip_user'] = 'true'; |
|
| 725 | + if ($skipUser) { |
|
| 726 | + $parameters['skip_user'] = 'true'; |
|
| 727 | + } |
|
| 693 | 728 | |
| 694 | 729 | // make the call |
| 695 | 730 | return (array)$this->doCall('statuses/public_timeline.json', $parameters); |
@@ -712,11 +747,21 @@ discard block |
||
| 712 | 747 | |
| 713 | 748 | // build parameters |
| 714 | 749 | $parameters = array(); |
| 715 | - if ($sinceId != null) $parameters['since_id'] = (string)$sinceId; |
|
| 716 | - if ($maxId != null) $parameters['max_id'] = (string)$maxId; |
|
| 717 | - if ($count != null) $parameters['count'] = (int)$count; |
|
| 718 | - if ($page != null) $parameters['page'] = (int)$page; |
|
| 719 | - if ($skipUser) $parameters['skip_user'] = 'true'; |
|
| 750 | + if ($sinceId != null) { |
|
| 751 | + $parameters['since_id'] = (string)$sinceId; |
|
| 752 | + } |
|
| 753 | + if ($maxId != null) { |
|
| 754 | + $parameters['max_id'] = (string)$maxId; |
|
| 755 | + } |
|
| 756 | + if ($count != null) { |
|
| 757 | + $parameters['count'] = (int)$count; |
|
| 758 | + } |
|
| 759 | + if ($page != null) { |
|
| 760 | + $parameters['page'] = (int)$page; |
|
| 761 | + } |
|
| 762 | + if ($skipUser) { |
|
| 763 | + $parameters['skip_user'] = 'true'; |
|
| 764 | + } |
|
| 720 | 765 | |
| 721 | 766 | // make the call |
| 722 | 767 | return (array)$this->doCall('statuses/home_timeline.json', $parameters, true); |
@@ -743,11 +788,21 @@ discard block |
||
| 743 | 788 | |
| 744 | 789 | // build parameters |
| 745 | 790 | $parameters = array(); |
| 746 | - if ($sinceId != null) $parameters['since_id'] = (string)$sinceId; |
|
| 747 | - if ($maxId != null) $parameters['max_id'] = (string)$maxId; |
|
| 748 | - if ($count != null) $parameters['count'] = (int)$count; |
|
| 749 | - if ($page != null) $parameters['page'] = (int)$page; |
|
| 750 | - if ($skipUser) $parameters['skip_user'] = 'true'; |
|
| 791 | + if ($sinceId != null) { |
|
| 792 | + $parameters['since_id'] = (string)$sinceId; |
|
| 793 | + } |
|
| 794 | + if ($maxId != null) { |
|
| 795 | + $parameters['max_id'] = (string)$maxId; |
|
| 796 | + } |
|
| 797 | + if ($count != null) { |
|
| 798 | + $parameters['count'] = (int)$count; |
|
| 799 | + } |
|
| 800 | + if ($page != null) { |
|
| 801 | + $parameters['page'] = (int)$page; |
|
| 802 | + } |
|
| 803 | + if ($skipUser) { |
|
| 804 | + $parameters['skip_user'] = 'true'; |
|
| 805 | + } |
|
| 751 | 806 | |
| 752 | 807 | // make the call |
| 753 | 808 | return (array)$this->doCall('statuses/friends_timeline.json', $parameters, true); |
@@ -777,14 +832,30 @@ discard block |
||
| 777 | 832 | |
| 778 | 833 | // build parameters |
| 779 | 834 | $parameters = array(); |
| 780 | - if ($id != null) $parameters['id'] = (string)$id; |
|
| 781 | - if ($userId != null) $parameters['user_id'] = (string)$userId; |
|
| 782 | - if ($screenName != null) $parameters['screen_name'] = (string)$screenName; |
|
| 783 | - if ($sinceId != null) $parameters['since_id'] = (string)$sinceId; |
|
| 784 | - if ($maxId != null) $parameters['max_id'] = (string)$maxId; |
|
| 785 | - if ($count != null) $parameters['count'] = (int)$count; |
|
| 786 | - if ($page != null) $parameters['page'] = (int)$page; |
|
| 787 | - if ($skipUser) $parameters['skip_user'] = 'true'; |
|
| 835 | + if ($id != null) { |
|
| 836 | + $parameters['id'] = (string)$id; |
|
| 837 | + } |
|
| 838 | + if ($userId != null) { |
|
| 839 | + $parameters['user_id'] = (string)$userId; |
|
| 840 | + } |
|
| 841 | + if ($screenName != null) { |
|
| 842 | + $parameters['screen_name'] = (string)$screenName; |
|
| 843 | + } |
|
| 844 | + if ($sinceId != null) { |
|
| 845 | + $parameters['since_id'] = (string)$sinceId; |
|
| 846 | + } |
|
| 847 | + if ($maxId != null) { |
|
| 848 | + $parameters['max_id'] = (string)$maxId; |
|
| 849 | + } |
|
| 850 | + if ($count != null) { |
|
| 851 | + $parameters['count'] = (int)$count; |
|
| 852 | + } |
|
| 853 | + if ($page != null) { |
|
| 854 | + $parameters['page'] = (int)$page; |
|
| 855 | + } |
|
| 856 | + if ($skipUser) { |
|
| 857 | + $parameters['skip_user'] = 'true'; |
|
| 858 | + } |
|
| 788 | 859 | |
| 789 | 860 | // make the call |
| 790 | 861 | return (array)$this->doCall('statuses/user_timeline.json', $parameters, true); |
@@ -808,14 +879,24 @@ discard block |
||
| 808 | 879 | public function statusesMentions($sinceId = null, $maxId = null, $count = null, $page = null) |
| 809 | 880 | { |
| 810 | 881 | // validate |
| 811 | - if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
| 882 | + if ($count != null && $count > 200) { |
|
| 883 | + throw new TwitterException('Count may not be greater than 200.'); |
|
| 884 | + } |
|
| 812 | 885 | |
| 813 | 886 | // build parameters |
| 814 | 887 | $parameters = array(); |
| 815 | - if ($sinceId != null) $parameters['since_id'] = (string)$sinceId; |
|
| 816 | - if ($maxId != null) $parameters['max_id'] = (string)$maxId; |
|
| 817 | - if ($count != null) $parameters['count'] = (int)$count; |
|
| 818 | - if ($page != null) $parameters['page'] = (int)$page; |
|
| 888 | + if ($sinceId != null) { |
|
| 889 | + $parameters['since_id'] = (string)$sinceId; |
|
| 890 | + } |
|
| 891 | + if ($maxId != null) { |
|
| 892 | + $parameters['max_id'] = (string)$maxId; |
|
| 893 | + } |
|
| 894 | + if ($count != null) { |
|
| 895 | + $parameters['count'] = (int)$count; |
|
| 896 | + } |
|
| 897 | + if ($page != null) { |
|
| 898 | + $parameters['page'] = (int)$page; |
|
| 899 | + } |
|
| 819 | 900 | |
| 820 | 901 | // make the call |
| 821 | 902 | return (array)$this->doCall('statuses/mentions.json', $parameters); |
@@ -839,14 +920,24 @@ discard block |
||
| 839 | 920 | public function statusesRetweetedByMe($sinceId = null, $maxId = null, $count = null, $page = null) |
| 840 | 921 | { |
| 841 | 922 | // validate |
| 842 | - if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
| 923 | + if ($count != null && $count > 200) { |
|
| 924 | + throw new TwitterException('Count may not be greater than 200.'); |
|
| 925 | + } |
|
| 843 | 926 | |
| 844 | 927 | // build parameters |
| 845 | 928 | $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; |
|
| 929 | + if ($sinceId != null) { |
|
| 930 | + $parameters['since_id'] = (string)$sinceId; |
|
| 931 | + } |
|
| 932 | + if ($maxId != null) { |
|
| 933 | + $parameters['max_id'] = (string)$maxId; |
|
| 934 | + } |
|
| 935 | + if ($count != null) { |
|
| 936 | + $parameters['count'] = (int)$count; |
|
| 937 | + } |
|
| 938 | + if ($page != null) { |
|
| 939 | + $parameters['page'] = (int)$page; |
|
| 940 | + } |
|
| 850 | 941 | |
| 851 | 942 | // make the call |
| 852 | 943 | return (array)$this->doCall('statuses/retweeted_by_me.json', $parameters); |
@@ -870,14 +961,24 @@ discard block |
||
| 870 | 961 | public function statusesRetweetedToMe($sinceId = null, $maxId = null, $count = null, $page = null) |
| 871 | 962 | { |
| 872 | 963 | // validate |
| 873 | - if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
| 964 | + if ($count != null && $count > 200) { |
|
| 965 | + throw new TwitterException('Count may not be greater than 200.'); |
|
| 966 | + } |
|
| 874 | 967 | |
| 875 | 968 | // build parameters |
| 876 | 969 | $parameters = array(); |
| 877 | - if ($sinceId != null) $parameters['since_id'] = (string)$sinceId; |
|
| 878 | - if ($maxId != null) $parameters['max_id'] = (string)$maxId; |
|
| 879 | - if ($count != null) $parameters['count'] = (int)$count; |
|
| 880 | - if ($page != null) $parameters['page'] = (int)$page; |
|
| 970 | + if ($sinceId != null) { |
|
| 971 | + $parameters['since_id'] = (string)$sinceId; |
|
| 972 | + } |
|
| 973 | + if ($maxId != null) { |
|
| 974 | + $parameters['max_id'] = (string)$maxId; |
|
| 975 | + } |
|
| 976 | + if ($count != null) { |
|
| 977 | + $parameters['count'] = (int)$count; |
|
| 978 | + } |
|
| 979 | + if ($page != null) { |
|
| 980 | + $parameters['page'] = (int)$page; |
|
| 981 | + } |
|
| 881 | 982 | |
| 882 | 983 | // make the call |
| 883 | 984 | return (array)$this->doCall('statuses/retweeted_by_me.json', $parameters); |
@@ -903,14 +1004,24 @@ discard block |
||
| 903 | 1004 | public function statusesReweetsOfMe($sinceId = null, $maxId = null, $count = null, $page = null) |
| 904 | 1005 | { |
| 905 | 1006 | // validate |
| 906 | - if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
| 1007 | + if ($count != null && $count > 200) { |
|
| 1008 | + throw new TwitterException('Count may not be greater than 200.'); |
|
| 1009 | + } |
|
| 907 | 1010 | |
| 908 | 1011 | // build parameters |
| 909 | 1012 | $parameters = array(); |
| 910 | - if ($sinceId != null) $parameters['since_id'] = (string)$sinceId; |
|
| 911 | - if ($maxId != null) $parameters['max_id'] = (string)$maxId; |
|
| 912 | - if ($count != null) $parameters['count'] = (int)$count; |
|
| 913 | - if ($page != null) $parameters['page'] = (int)$page; |
|
| 1013 | + if ($sinceId != null) { |
|
| 1014 | + $parameters['since_id'] = (string)$sinceId; |
|
| 1015 | + } |
|
| 1016 | + if ($maxId != null) { |
|
| 1017 | + $parameters['max_id'] = (string)$maxId; |
|
| 1018 | + } |
|
| 1019 | + if ($count != null) { |
|
| 1020 | + $parameters['count'] = (int)$count; |
|
| 1021 | + } |
|
| 1022 | + if ($page != null) { |
|
| 1023 | + $parameters['page'] = (int)$page; |
|
| 1024 | + } |
|
| 914 | 1025 | |
| 915 | 1026 | // make the call |
| 916 | 1027 | return (array)$this->doCall('statuses/retweets_of_me.json', $parameters); |
@@ -946,11 +1057,21 @@ discard block |
||
| 946 | 1057 | { |
| 947 | 1058 | // build parameters |
| 948 | 1059 | $parameters['status'] = (string)$status; |
| 949 | - if ($inReplyToStatusId != null) $parameters['in_reply_to_status_id'] = (string)$inReplyToStatusId; |
|
| 950 | - if ($lat != null) $parameters['lat'] = (float)$lat; |
|
| 951 | - if ($long != null) $parameters['long'] = (float)$long; |
|
| 952 | - if ($placeId != null) $parameters['place_id'] = (string)$placeId; |
|
| 953 | - if ($displayCoordinates) $parameters['display_coordinates'] = 'true'; |
|
| 1060 | + if ($inReplyToStatusId != null) { |
|
| 1061 | + $parameters['in_reply_to_status_id'] = (string)$inReplyToStatusId; |
|
| 1062 | + } |
|
| 1063 | + if ($lat != null) { |
|
| 1064 | + $parameters['lat'] = (float)$lat; |
|
| 1065 | + } |
|
| 1066 | + if ($long != null) { |
|
| 1067 | + $parameters['long'] = (float)$long; |
|
| 1068 | + } |
|
| 1069 | + if ($placeId != null) { |
|
| 1070 | + $parameters['place_id'] = (string)$placeId; |
|
| 1071 | + } |
|
| 1072 | + if ($displayCoordinates) { |
|
| 1073 | + $parameters['display_coordinates'] = 'true'; |
|
| 1074 | + } |
|
| 954 | 1075 | |
| 955 | 1076 | // make the call |
| 956 | 1077 | return (array)$this->doCall('statuses/update.json', $parameters, true, 'POST'); |
@@ -996,11 +1117,15 @@ discard block |
||
| 996 | 1117 | public function statusesRetweets($id, $count = null) |
| 997 | 1118 | { |
| 998 | 1119 | // validate |
| 999 | - if ($count != null && $count > 100) throw new TwitterException('Count may not be greater than 100.'); |
|
| 1120 | + if ($count != null && $count > 100) { |
|
| 1121 | + throw new TwitterException('Count may not be greater than 100.'); |
|
| 1122 | + } |
|
| 1000 | 1123 | |
| 1001 | 1124 | // build parameters |
| 1002 | 1125 | $parameters = null; |
| 1003 | - if ($count != null) $parameters['count'] = (int)$count; |
|
| 1126 | + if ($count != null) { |
|
| 1127 | + $parameters['count'] = (int)$count; |
|
| 1128 | + } |
|
| 1004 | 1129 | |
| 1005 | 1130 | // make the call |
| 1006 | 1131 | return (array)$this->doCall('statuses/retweets/' . $id . '.json', $parameters); |
@@ -1021,12 +1146,18 @@ discard block |
||
| 1021 | 1146 | public function statusesIdRetweetedBy($id, $count = null, $page = null) |
| 1022 | 1147 | { |
| 1023 | 1148 | // validate |
| 1024 | - if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
| 1149 | + if ($count != null && $count > 200) { |
|
| 1150 | + throw new TwitterException('Count may not be greater than 200.'); |
|
| 1151 | + } |
|
| 1025 | 1152 | |
| 1026 | 1153 | // build parameters |
| 1027 | 1154 | $parameters = null; |
| 1028 | - if ($count != null) $parameters['count'] = (int)$count; |
|
| 1029 | - if ($page != null) $parameters['page'] = (int)$page; |
|
| 1155 | + if ($count != null) { |
|
| 1156 | + $parameters['count'] = (int)$count; |
|
| 1157 | + } |
|
| 1158 | + if ($page != null) { |
|
| 1159 | + $parameters['page'] = (int)$page; |
|
| 1160 | + } |
|
| 1030 | 1161 | |
| 1031 | 1162 | // make the call |
| 1032 | 1163 | return (array)$this->doCall('statuses/' . (string)$id . '/retweeted_by.json', $parameters, true); |
@@ -1047,12 +1178,18 @@ discard block |
||
| 1047 | 1178 | public function statusesIdRetweetedByIds($id, $count = null, $page = null) |
| 1048 | 1179 | { |
| 1049 | 1180 | // validate |
| 1050 | - if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
| 1181 | + if ($count != null && $count > 200) { |
|
| 1182 | + throw new TwitterException('Count may not be greater than 200.'); |
|
| 1183 | + } |
|
| 1051 | 1184 | |
| 1052 | 1185 | // build parameters |
| 1053 | 1186 | $parameters = null; |
| 1054 | - if ($count != null) $parameters['count'] = (int)$count; |
|
| 1055 | - if ($page != null) $parameters['page'] = (int)$page; |
|
| 1187 | + if ($count != null) { |
|
| 1188 | + $parameters['count'] = (int)$count; |
|
| 1189 | + } |
|
| 1190 | + if ($page != null) { |
|
| 1191 | + $parameters['page'] = (int)$page; |
|
| 1192 | + } |
|
| 1056 | 1193 | |
| 1057 | 1194 | // make the call |
| 1058 | 1195 | return (array)$this->doCall('statuses/' . (string)$id . '/retweeted_by/ids.json', $parameters, true); |
@@ -1077,12 +1214,20 @@ discard block |
||
| 1077 | 1214 | public function usersShow($id = null, $userId = null, $screenName = null) |
| 1078 | 1215 | { |
| 1079 | 1216 | // validate |
| 1080 | - if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 1217 | + if ($id == '' && $userId == '' && $screenName == '') { |
|
| 1218 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 1219 | + } |
|
| 1081 | 1220 | |
| 1082 | 1221 | // build parameters |
| 1083 | - if ($id != null) $parameters['id'] = (string)$id; |
|
| 1084 | - if ($userId != null) $parameters['user_id'] = (string)$userId; |
|
| 1085 | - if ($screenName != null) $parameters['screen_name'] = (string)$screenName; |
|
| 1222 | + if ($id != null) { |
|
| 1223 | + $parameters['id'] = (string)$id; |
|
| 1224 | + } |
|
| 1225 | + if ($userId != null) { |
|
| 1226 | + $parameters['user_id'] = (string)$userId; |
|
| 1227 | + } |
|
| 1228 | + if ($screenName != null) { |
|
| 1229 | + $parameters['screen_name'] = (string)$screenName; |
|
| 1230 | + } |
|
| 1086 | 1231 | |
| 1087 | 1232 | // make the call |
| 1088 | 1233 | return (array)$this->doCall('users/show.json', $parameters); |
@@ -1107,11 +1252,17 @@ discard block |
||
| 1107 | 1252 | $screenNames = (array)$screenNames; |
| 1108 | 1253 | |
| 1109 | 1254 | // validate |
| 1110 | - if (empty($userIds) && empty($screenNames)) throw new TwitterException('Specify an userId or a screenName.'); |
|
| 1255 | + if (empty($userIds) && empty($screenNames)) { |
|
| 1256 | + throw new TwitterException('Specify an userId or a screenName.'); |
|
| 1257 | + } |
|
| 1111 | 1258 | |
| 1112 | 1259 | // build parameters |
| 1113 | - if (!empty($userIds)) $parameters['user_id'] = implode(',', $userIds); |
|
| 1114 | - if (!empty($screenNames)) $parameters['screen_name'] = implode(',', $screenNames); |
|
| 1260 | + if (!empty($userIds)) { |
|
| 1261 | + $parameters['user_id'] = implode(',', $userIds); |
|
| 1262 | + } |
|
| 1263 | + if (!empty($screenNames)) { |
|
| 1264 | + $parameters['screen_name'] = implode(',', $screenNames); |
|
| 1265 | + } |
|
| 1115 | 1266 | |
| 1116 | 1267 | // make the call |
| 1117 | 1268 | return (array)$this->doCall('users/lookup.json', $parameters, true); |
@@ -1131,8 +1282,12 @@ discard block |
||
| 1131 | 1282 | { |
| 1132 | 1283 | // build parameters |
| 1133 | 1284 | $parameters['q'] = (string)$q; |
| 1134 | - if ($perPage != null) $parameters['per_page'] = (int)$perPage; |
|
| 1135 | - if ($page != null) $parameters['page'] = (int)$page; |
|
| 1285 | + if ($perPage != null) { |
|
| 1286 | + $parameters['per_page'] = (int)$perPage; |
|
| 1287 | + } |
|
| 1288 | + if ($page != null) { |
|
| 1289 | + $parameters['page'] = (int)$page; |
|
| 1290 | + } |
|
| 1136 | 1291 | |
| 1137 | 1292 | // make the call |
| 1138 | 1293 | return (array)$this->doCall('users/search.json', $parameters, true); |
@@ -1179,10 +1334,18 @@ discard block |
||
| 1179 | 1334 | { |
| 1180 | 1335 | // build parameters |
| 1181 | 1336 | $parameters = array(); |
| 1182 | - if ($id != null) $parameters['id'] = (string)$id; |
|
| 1183 | - if ($userId != null) $parameters['user_id'] = (string)$userId; |
|
| 1184 | - if ($screenName != null) $parameters['screen_name'] = (string)$screenName; |
|
| 1185 | - if ($cursor != null) $parameters['cursor'] = (int)$cursor; |
|
| 1337 | + if ($id != null) { |
|
| 1338 | + $parameters['id'] = (string)$id; |
|
| 1339 | + } |
|
| 1340 | + if ($userId != null) { |
|
| 1341 | + $parameters['user_id'] = (string)$userId; |
|
| 1342 | + } |
|
| 1343 | + if ($screenName != null) { |
|
| 1344 | + $parameters['screen_name'] = (string)$screenName; |
|
| 1345 | + } |
|
| 1346 | + if ($cursor != null) { |
|
| 1347 | + $parameters['cursor'] = (int)$cursor; |
|
| 1348 | + } |
|
| 1186 | 1349 | |
| 1187 | 1350 | // make the call |
| 1188 | 1351 | return (array)$this->doCall('statuses/friends.json', $parameters); |
@@ -1202,10 +1365,18 @@ discard block |
||
| 1202 | 1365 | { |
| 1203 | 1366 | // build parameters |
| 1204 | 1367 | $parameters = array(); |
| 1205 | - if ($id != null) $parameters['id'] = (string)$id; |
|
| 1206 | - if ($userId != null) $parameters['user_id'] = (string)$userId; |
|
| 1207 | - if ($screenName != null) $parameters['screen_name'] = (string)$screenName; |
|
| 1208 | - if ($cursor != null) $parameters['cursor'] = (int)$cursor; |
|
| 1368 | + if ($id != null) { |
|
| 1369 | + $parameters['id'] = (string)$id; |
|
| 1370 | + } |
|
| 1371 | + if ($userId != null) { |
|
| 1372 | + $parameters['user_id'] = (string)$userId; |
|
| 1373 | + } |
|
| 1374 | + if ($screenName != null) { |
|
| 1375 | + $parameters['screen_name'] = (string)$screenName; |
|
| 1376 | + } |
|
| 1377 | + if ($cursor != null) { |
|
| 1378 | + $parameters['cursor'] = (int)$cursor; |
|
| 1379 | + } |
|
| 1209 | 1380 | |
| 1210 | 1381 | // make the call |
| 1211 | 1382 | return (array)$this->doCall('statuses/followers.json', $parameters); |
@@ -1235,7 +1406,9 @@ discard block |
||
| 1235 | 1406 | { |
| 1236 | 1407 | // build parameters |
| 1237 | 1408 | $parameters = array(); |
| 1238 | - if ($exclude != null) $parameters['exclude'] = (string)$exclude; |
|
| 1409 | + if ($exclude != null) { |
|
| 1410 | + $parameters['exclude'] = (string)$exclude; |
|
| 1411 | + } |
|
| 1239 | 1412 | |
| 1240 | 1413 | // make the call |
| 1241 | 1414 | return (array)$this->doCall('trends/current.json', $parameters); |
@@ -1252,8 +1425,12 @@ discard block |
||
| 1252 | 1425 | { |
| 1253 | 1426 | // build parameters |
| 1254 | 1427 | $parameters = array(); |
| 1255 | - if ($exclude != null) $parameters['exclude'] = (string)$exclude; |
|
| 1256 | - if ($date != null) $parameters['date'] = (string)$date; |
|
| 1428 | + if ($exclude != null) { |
|
| 1429 | + $parameters['exclude'] = (string)$exclude; |
|
| 1430 | + } |
|
| 1431 | + if ($date != null) { |
|
| 1432 | + $parameters['date'] = (string)$date; |
|
| 1433 | + } |
|
| 1257 | 1434 | |
| 1258 | 1435 | // make the call |
| 1259 | 1436 | return (array)$this->doCall('trends/daily.json', $parameters); |
@@ -1270,8 +1447,12 @@ discard block |
||
| 1270 | 1447 | { |
| 1271 | 1448 | // build parameters |
| 1272 | 1449 | $parameters = array(); |
| 1273 | - if ($exclude != null) $parameters['exclude'] = (string)$exclude; |
|
| 1274 | - if ($date != null) $parameters['date'] = (string)$date; |
|
| 1450 | + if ($exclude != null) { |
|
| 1451 | + $parameters['exclude'] = (string)$exclude; |
|
| 1452 | + } |
|
| 1453 | + if ($date != null) { |
|
| 1454 | + $parameters['date'] = (string)$date; |
|
| 1455 | + } |
|
| 1275 | 1456 | |
| 1276 | 1457 | // make the call |
| 1277 | 1458 | return (array)$this->doCall('trends/weekly.json', $parameters); |
@@ -1298,12 +1479,18 @@ discard block |
||
| 1298 | 1479 | $allowedModes = array('public', 'private'); |
| 1299 | 1480 | |
| 1300 | 1481 | // validate |
| 1301 | - if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.'); |
|
| 1482 | + if ($mode != null && !in_array($mode, $allowedModes)) { |
|
| 1483 | + throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.'); |
|
| 1484 | + } |
|
| 1302 | 1485 | |
| 1303 | 1486 | // build parameters |
| 1304 | 1487 | $parameters['name'] = (string)$name; |
| 1305 | - if ($mode != null) $parameters['mode'] = (string)$mode; |
|
| 1306 | - if ($description != null) $parameters['description'] = (string)$description; |
|
| 1488 | + if ($mode != null) { |
|
| 1489 | + $parameters['mode'] = (string)$mode; |
|
| 1490 | + } |
|
| 1491 | + if ($description != null) { |
|
| 1492 | + $parameters['description'] = (string)$description; |
|
| 1493 | + } |
|
| 1307 | 1494 | |
| 1308 | 1495 | // make the call |
| 1309 | 1496 | return (array)$this->doCall((string)$user . '/lists.json', $parameters, true, 'POST'); |
@@ -1319,7 +1506,9 @@ discard block |
||
| 1319 | 1506 | public function userLists($user, $cursor = null) |
| 1320 | 1507 | { |
| 1321 | 1508 | $parameters = null; |
| 1322 | - if ($cursor != null) $parameters['cursor'] = (string)$cursor; |
|
| 1509 | + if ($cursor != null) { |
|
| 1510 | + $parameters['cursor'] = (string)$cursor; |
|
| 1511 | + } |
|
| 1323 | 1512 | |
| 1324 | 1513 | // make the call |
| 1325 | 1514 | return (array)$this->doCall((string)$user . '/lists.json', $parameters, true); |
@@ -1359,12 +1548,20 @@ discard block |
||
| 1359 | 1548 | $allowedModes = array('public', 'private'); |
| 1360 | 1549 | |
| 1361 | 1550 | // validate |
| 1362 | - if ($mode != null && !in_array($mode, $allowedModes)) throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.'); |
|
| 1551 | + if ($mode != null && !in_array($mode, $allowedModes)) { |
|
| 1552 | + throw new TwitterException('Invalid mode (), possible values are: ' . implode($allowedModes) . '.'); |
|
| 1553 | + } |
|
| 1363 | 1554 | |
| 1364 | 1555 | // build parameters |
| 1365 | - if ($name != null) $parameters['name'] = (string)$name; |
|
| 1366 | - if ($mode != null) $parameters['mode'] = (string)$mode; |
|
| 1367 | - if ($description != null) $parameters['description'] = (string)$description; |
|
| 1556 | + if ($name != null) { |
|
| 1557 | + $parameters['name'] = (string)$name; |
|
| 1558 | + } |
|
| 1559 | + if ($mode != null) { |
|
| 1560 | + $parameters['mode'] = (string)$mode; |
|
| 1561 | + } |
|
| 1562 | + if ($description != null) { |
|
| 1563 | + $parameters['description'] = (string)$description; |
|
| 1564 | + } |
|
| 1368 | 1565 | |
| 1369 | 1566 | // make the call |
| 1370 | 1567 | return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '.json', $parameters, true, 'POST'); |
@@ -1390,14 +1587,24 @@ discard block |
||
| 1390 | 1587 | public function userListsIdStatuses($user, $id, $sinceId = null, $maxId = null, $count = null, $page = null) |
| 1391 | 1588 | { |
| 1392 | 1589 | // validate |
| 1393 | - if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
| 1590 | + if ($count != null && $count > 200) { |
|
| 1591 | + throw new TwitterException('Count may not be greater than 200.'); |
|
| 1592 | + } |
|
| 1394 | 1593 | |
| 1395 | 1594 | // build parameters |
| 1396 | 1595 | $parameters = array(); |
| 1397 | - if ($sinceId != null) $parameters['since_id'] = (string)$sinceId; |
|
| 1398 | - if ($maxId != null) $parameters['max_id'] = (string)$maxId; |
|
| 1399 | - if ($count != null) $parameters['per_page'] = (int)$count; |
|
| 1400 | - if ($page != null) $parameters['page'] = (int)$page; |
|
| 1596 | + if ($sinceId != null) { |
|
| 1597 | + $parameters['since_id'] = (string)$sinceId; |
|
| 1598 | + } |
|
| 1599 | + if ($maxId != null) { |
|
| 1600 | + $parameters['max_id'] = (string)$maxId; |
|
| 1601 | + } |
|
| 1602 | + if ($count != null) { |
|
| 1603 | + $parameters['per_page'] = (int)$count; |
|
| 1604 | + } |
|
| 1605 | + if ($page != null) { |
|
| 1606 | + $parameters['page'] = (int)$page; |
|
| 1607 | + } |
|
| 1401 | 1608 | |
| 1402 | 1609 | // make the call |
| 1403 | 1610 | return (array)$this->doCall((string)$user . '/lists/' . (string)$id . '/statuses.json', $parameters); |
@@ -1413,7 +1620,9 @@ discard block |
||
| 1413 | 1620 | public function userListsMemberships($user, $cursor = null) |
| 1414 | 1621 | { |
| 1415 | 1622 | $parameters = null; |
| 1416 | - if ($cursor != null) $parameters['cursor'] = (string)$cursor; |
|
| 1623 | + if ($cursor != null) { |
|
| 1624 | + $parameters['cursor'] = (string)$cursor; |
|
| 1625 | + } |
|
| 1417 | 1626 | |
| 1418 | 1627 | // make the call |
| 1419 | 1628 | return (array)$this->doCall((string)$user . '/lists/memberships.json', $parameters, true); |
@@ -1429,7 +1638,9 @@ discard block |
||
| 1429 | 1638 | public function userListsSubscriptions($user, $cursor = null) |
| 1430 | 1639 | { |
| 1431 | 1640 | $parameters = null; |
| 1432 | - if ($cursor != null) $parameters['cursor'] = (string)$cursor; |
|
| 1641 | + if ($cursor != null) { |
|
| 1642 | + $parameters['cursor'] = (string)$cursor; |
|
| 1643 | + } |
|
| 1433 | 1644 | |
| 1434 | 1645 | // make the call |
| 1435 | 1646 | return (array)$this->doCall((string)$user . '/lists/subscriptions.json', $parameters, true); |
@@ -1448,7 +1659,9 @@ discard block |
||
| 1448 | 1659 | public function userListMembers($user, $id, $cursor = null) |
| 1449 | 1660 | { |
| 1450 | 1661 | $parameters = null; |
| 1451 | - if ($cursor != null) $parameters['cursor'] = (string)$cursor; |
|
| 1662 | + if ($cursor != null) { |
|
| 1663 | + $parameters['cursor'] = (string)$cursor; |
|
| 1664 | + } |
|
| 1452 | 1665 | |
| 1453 | 1666 | // make the call |
| 1454 | 1667 | return (array)$this->doCall((string)$user . '/' . (string)$id . '/members.json', $parameters, true); |
@@ -1508,7 +1721,9 @@ discard block |
||
| 1508 | 1721 | catch (TwitterException $e) { |
| 1509 | 1722 | if ($e->getMessage() === 'The specified user is not a member of this list') { |
| 1510 | 1723 | return false; |
| 1511 | - } else throw $e; |
|
| 1724 | + } else { |
|
| 1725 | + throw $e; |
|
| 1726 | + } |
|
| 1512 | 1727 | } |
| 1513 | 1728 | } |
| 1514 | 1729 | |
@@ -1525,7 +1740,9 @@ discard block |
||
| 1525 | 1740 | public function userListSubscribers($user, $id, $cursor = null) |
| 1526 | 1741 | { |
| 1527 | 1742 | $parameters = null; |
| 1528 | - if ($cursor != null) $parameters['cursor'] = (string)$cursor; |
|
| 1743 | + if ($cursor != null) { |
|
| 1744 | + $parameters['cursor'] = (string)$cursor; |
|
| 1745 | + } |
|
| 1529 | 1746 | |
| 1530 | 1747 | // make the call |
| 1531 | 1748 | return (array)$this->doCall((string)$user . '/' . (string)$id . '/subscribers.json', $parameters, true); |
@@ -1579,7 +1796,9 @@ discard block |
||
| 1579 | 1796 | catch (TwitterException $e) { |
| 1580 | 1797 | if ($e->getMessage() === 'The specified user is not a subscriber of this list') { |
| 1581 | 1798 | return false; |
| 1582 | - } else throw $e; |
|
| 1799 | + } else { |
|
| 1800 | + throw $e; |
|
| 1801 | + } |
|
| 1583 | 1802 | } |
| 1584 | 1803 | |
| 1585 | 1804 | } |
@@ -1604,14 +1823,24 @@ discard block |
||
| 1604 | 1823 | public function directMessages($sinceId = null, $maxId = null, $count = null, $page = null) |
| 1605 | 1824 | { |
| 1606 | 1825 | // validate |
| 1607 | - if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
| 1826 | + if ($count != null && $count > 200) { |
|
| 1827 | + throw new TwitterException('Count may not be greater than 200.'); |
|
| 1828 | + } |
|
| 1608 | 1829 | |
| 1609 | 1830 | // build parameters |
| 1610 | 1831 | $parameters = array(); |
| 1611 | - if ($sinceId != null) $parameters['since_id'] = (string)$sinceId; |
|
| 1612 | - if ($maxId != null) $parameters['max_id'] = (string)$maxId; |
|
| 1613 | - if ($count != null) $parameters['count'] = (int)$count; |
|
| 1614 | - if ($page != null) $parameters['page'] = (int)$page; |
|
| 1832 | + if ($sinceId != null) { |
|
| 1833 | + $parameters['since_id'] = (string)$sinceId; |
|
| 1834 | + } |
|
| 1835 | + if ($maxId != null) { |
|
| 1836 | + $parameters['max_id'] = (string)$maxId; |
|
| 1837 | + } |
|
| 1838 | + if ($count != null) { |
|
| 1839 | + $parameters['count'] = (int)$count; |
|
| 1840 | + } |
|
| 1841 | + if ($page != null) { |
|
| 1842 | + $parameters['page'] = (int)$page; |
|
| 1843 | + } |
|
| 1615 | 1844 | |
| 1616 | 1845 | // make the call |
| 1617 | 1846 | return (array)$this->doCall('direct_messages.json', $parameters, true); |
@@ -1635,14 +1864,24 @@ discard block |
||
| 1635 | 1864 | public function directMessagesSent($sinceId = null, $maxId = null, $count = null, $page = null) |
| 1636 | 1865 | { |
| 1637 | 1866 | // validate |
| 1638 | - if ($count != null && $count > 200) throw new TwitterException('Count may not be greater than 200.'); |
|
| 1867 | + if ($count != null && $count > 200) { |
|
| 1868 | + throw new TwitterException('Count may not be greater than 200.'); |
|
| 1869 | + } |
|
| 1639 | 1870 | |
| 1640 | 1871 | // build parameters |
| 1641 | 1872 | $parameters = array(); |
| 1642 | - if ($sinceId != null) $parameters['since_id'] = (string)$sinceId; |
|
| 1643 | - if ($maxId != null) $parameters['max_id'] = (string)$maxId; |
|
| 1644 | - if ($count != null) $parameters['count'] = (int)$count; |
|
| 1645 | - if ($page != null) $parameters['page'] = (int)$page; |
|
| 1873 | + if ($sinceId != null) { |
|
| 1874 | + $parameters['since_id'] = (string)$sinceId; |
|
| 1875 | + } |
|
| 1876 | + if ($maxId != null) { |
|
| 1877 | + $parameters['max_id'] = (string)$maxId; |
|
| 1878 | + } |
|
| 1879 | + if ($count != null) { |
|
| 1880 | + $parameters['count'] = (int)$count; |
|
| 1881 | + } |
|
| 1882 | + if ($page != null) { |
|
| 1883 | + $parameters['page'] = (int)$page; |
|
| 1884 | + } |
|
| 1646 | 1885 | |
| 1647 | 1886 | // make the call |
| 1648 | 1887 | return (array)$this->doCall('direct_messages/sent.json', $parameters, true); |
@@ -1666,13 +1905,21 @@ discard block |
||
| 1666 | 1905 | public function directMessagesNew($text, $id = null, $userId = null, $screenName = null) |
| 1667 | 1906 | { |
| 1668 | 1907 | // validate |
| 1669 | - 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 | + } |
|
| 1670 | 1911 | |
| 1671 | 1912 | // build parameters |
| 1672 | 1913 | $parameters['text'] = (string)$text; |
| 1673 | - if ($id != null) $parameters['user'] = (string)$id; |
|
| 1674 | - if ($userId != null) $parameters['user_id'] = (string)$userId; |
|
| 1675 | - 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 | + } |
|
| 1676 | 1923 | |
| 1677 | 1924 | // make the call |
| 1678 | 1925 | return (array)$this->doCall('direct_messages/new.json', $parameters, true, 'POST'); |
@@ -1715,12 +1962,20 @@ discard block |
||
| 1715 | 1962 | public function friendshipsCreate($id = null, $userId = null, $screenName = null, $follow = false) |
| 1716 | 1963 | { |
| 1717 | 1964 | // validate |
| 1718 | - if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 1965 | + if ($id == '' && $userId == '' && $screenName == '') { |
|
| 1966 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 1967 | + } |
|
| 1719 | 1968 | |
| 1720 | 1969 | // build parameters |
| 1721 | - if ($id != null) $parameters['id'] = (string)$id; |
|
| 1722 | - if ($userId != null) $parameters['user_id'] = (string)$userId; |
|
| 1723 | - if ($screenName != null) $parameters['screen_name'] = (string)$screenName; |
|
| 1970 | + if ($id != null) { |
|
| 1971 | + $parameters['id'] = (string)$id; |
|
| 1972 | + } |
|
| 1973 | + if ($userId != null) { |
|
| 1974 | + $parameters['user_id'] = (string)$userId; |
|
| 1975 | + } |
|
| 1976 | + if ($screenName != null) { |
|
| 1977 | + $parameters['screen_name'] = (string)$screenName; |
|
| 1978 | + } |
|
| 1724 | 1979 | $parameters['follow'] = $follow ? 'true' : 'false'; |
| 1725 | 1980 | |
| 1726 | 1981 | // make the call |
@@ -1744,12 +1999,20 @@ discard block |
||
| 1744 | 1999 | public function friendshipsDestroy($id = null, $userId = null, $screenName = null) |
| 1745 | 2000 | { |
| 1746 | 2001 | // validate |
| 1747 | - if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2002 | + if ($id == '' && $userId == '' && $screenName == '') { |
|
| 2003 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2004 | + } |
|
| 1748 | 2005 | |
| 1749 | 2006 | // build parameters |
| 1750 | - if ($id != null) $parameters['id'] = (string)$id; |
|
| 1751 | - if ($userId != null) $parameters['user_id'] = (string)$userId; |
|
| 1752 | - if ($screenName != null) $parameters['screen_name'] = (string)$screenName; |
|
| 2007 | + if ($id != null) { |
|
| 2008 | + $parameters['id'] = (string)$id; |
|
| 2009 | + } |
|
| 2010 | + if ($userId != null) { |
|
| 2011 | + $parameters['user_id'] = (string)$userId; |
|
| 2012 | + } |
|
| 2013 | + if ($screenName != null) { |
|
| 2014 | + $parameters['screen_name'] = (string)$screenName; |
|
| 2015 | + } |
|
| 1753 | 2016 | |
| 1754 | 2017 | // make the call |
| 1755 | 2018 | return (array)$this->doCall('friendships/destroy.json', $parameters, true, 'POST'); |
@@ -1790,14 +2053,26 @@ discard block |
||
| 1790 | 2053 | public function friendshipsShow($sourceId = null, $sourceScreenName = null, $targetId = null, $targetScreenName = null) |
| 1791 | 2054 | { |
| 1792 | 2055 | // validate |
| 1793 | - if ($sourceId == '' && $sourceScreenName == '') throw new TwitterException('Specify an sourceId or a sourceScreenName.'); |
|
| 1794 | - if ($targetId == '' && $targetScreenName == '') throw new TwitterException('Specify an targetId or a targetScreenName.'); |
|
| 2056 | + if ($sourceId == '' && $sourceScreenName == '') { |
|
| 2057 | + throw new TwitterException('Specify an sourceId or a sourceScreenName.'); |
|
| 2058 | + } |
|
| 2059 | + if ($targetId == '' && $targetScreenName == '') { |
|
| 2060 | + throw new TwitterException('Specify an targetId or a targetScreenName.'); |
|
| 2061 | + } |
|
| 1795 | 2062 | |
| 1796 | 2063 | // build parameters |
| 1797 | - if ($sourceId != null) $parameters['source_id'] = (string)$sourceId; |
|
| 1798 | - if ($sourceScreenName != null) $parameters['source_screen_name'] = (string)$sourceScreenName; |
|
| 1799 | - if ($targetId != null) $parameters['target_id'] = (string)$targetId; |
|
| 1800 | - if ($targetScreenName != null) $parameters['target_screen_name'] = (string)$targetScreenName; |
|
| 2064 | + if ($sourceId != null) { |
|
| 2065 | + $parameters['source_id'] = (string)$sourceId; |
|
| 2066 | + } |
|
| 2067 | + if ($sourceScreenName != null) { |
|
| 2068 | + $parameters['source_screen_name'] = (string)$sourceScreenName; |
|
| 2069 | + } |
|
| 2070 | + if ($targetId != null) { |
|
| 2071 | + $parameters['target_id'] = (string)$targetId; |
|
| 2072 | + } |
|
| 2073 | + if ($targetScreenName != null) { |
|
| 2074 | + $parameters['target_screen_name'] = (string)$targetScreenName; |
|
| 2075 | + } |
|
| 1801 | 2076 | |
| 1802 | 2077 | // make the call |
| 1803 | 2078 | return (array)$this->doCall('friendships/show.json', $parameters); |
@@ -1812,7 +2087,9 @@ discard block |
||
| 1812 | 2087 | public function friendshipsIncoming($cursor = null) |
| 1813 | 2088 | { |
| 1814 | 2089 | $parameters = null; |
| 1815 | - if ($cursor != null) $parameters['cursor'] = (string)$cursor; |
|
| 2090 | + if ($cursor != null) { |
|
| 2091 | + $parameters['cursor'] = (string)$cursor; |
|
| 2092 | + } |
|
| 1816 | 2093 | |
| 1817 | 2094 | // make the call |
| 1818 | 2095 | return (array)$this->doCall('friendships/incoming.json', $parameters, true); |
@@ -1827,7 +2104,9 @@ discard block |
||
| 1827 | 2104 | public function friendshipsOutgoing($cursor = null) |
| 1828 | 2105 | { |
| 1829 | 2106 | $parameters = null; |
| 1830 | - if ($cursor != null) $parameters['cursor'] = (string)$cursor; |
|
| 2107 | + if ($cursor != null) { |
|
| 2108 | + $parameters['cursor'] = (string)$cursor; |
|
| 2109 | + } |
|
| 1831 | 2110 | |
| 1832 | 2111 | // make the call |
| 1833 | 2112 | return (array)$this->doCall('friendships/outgoing.json', $parameters, true); |
@@ -1853,13 +2132,23 @@ discard block |
||
| 1853 | 2132 | public function friendsIds($id = null, $userId = null, $screenName = null, $cursor = null) |
| 1854 | 2133 | { |
| 1855 | 2134 | // validate |
| 1856 | - if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2135 | + if ($id == '' && $userId == '' && $screenName == '') { |
|
| 2136 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2137 | + } |
|
| 1857 | 2138 | |
| 1858 | 2139 | // build parameters |
| 1859 | - if ($id != null) $parameters['id'] = (string)$id; |
|
| 1860 | - if ($userId != null) $parameters['user_id'] = (string)$userId; |
|
| 1861 | - if ($screenName != null) $parameters['screen_name'] = (string)$screenName; |
|
| 1862 | - if ($cursor != null) $parameters['cursor'] = (string)$cursor; |
|
| 2140 | + if ($id != null) { |
|
| 2141 | + $parameters['id'] = (string)$id; |
|
| 2142 | + } |
|
| 2143 | + if ($userId != null) { |
|
| 2144 | + $parameters['user_id'] = (string)$userId; |
|
| 2145 | + } |
|
| 2146 | + if ($screenName != null) { |
|
| 2147 | + $parameters['screen_name'] = (string)$screenName; |
|
| 2148 | + } |
|
| 2149 | + if ($cursor != null) { |
|
| 2150 | + $parameters['cursor'] = (string)$cursor; |
|
| 2151 | + } |
|
| 1863 | 2152 | |
| 1864 | 2153 | // make the call |
| 1865 | 2154 | return (array)$this->doCall('friends/ids.json', $parameters); |
@@ -1883,13 +2172,23 @@ discard block |
||
| 1883 | 2172 | public function followersIds($id = null, $userId = null, $screenName = null, $cursor = null) |
| 1884 | 2173 | { |
| 1885 | 2174 | // validate |
| 1886 | - if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2175 | + if ($id == '' && $userId == '' && $screenName == '') { |
|
| 2176 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2177 | + } |
|
| 1887 | 2178 | |
| 1888 | 2179 | // build parameters |
| 1889 | - if ($id != null) $parameters['id'] = (string)$id; |
|
| 1890 | - if ($userId != null) $parameters['user_id'] = (string)$userId; |
|
| 1891 | - if ($screenName != null) $parameters['screen_name'] = (string)$screenName; |
|
| 1892 | - if ($cursor != null) $parameters['cursor'] = (string)$cursor; |
|
| 2180 | + if ($id != null) { |
|
| 2181 | + $parameters['id'] = (string)$id; |
|
| 2182 | + } |
|
| 2183 | + if ($userId != null) { |
|
| 2184 | + $parameters['user_id'] = (string)$userId; |
|
| 2185 | + } |
|
| 2186 | + if ($screenName != null) { |
|
| 2187 | + $parameters['screen_name'] = (string)$screenName; |
|
| 2188 | + } |
|
| 2189 | + if ($cursor != null) { |
|
| 2190 | + $parameters['cursor'] = (string)$cursor; |
|
| 2191 | + } |
|
| 1893 | 2192 | |
| 1894 | 2193 | // make the call |
| 1895 | 2194 | return (array)$this->doCall('followers/ids.json', $parameters); |
@@ -1932,7 +2231,9 @@ discard block |
||
| 1932 | 2231 | catch (TwitterException $e) { |
| 1933 | 2232 | if ($e->getMessage() === 'Logged out.') { |
| 1934 | 2233 | return true; |
| 1935 | - } else throw $e; |
|
| 2234 | + } else { |
|
| 2235 | + throw $e; |
|
| 2236 | + } |
|
| 1936 | 2237 | } |
| 1937 | 2238 | } |
| 1938 | 2239 | |
@@ -1974,14 +2275,26 @@ discard block |
||
| 1974 | 2275 | // validate |
| 1975 | 2276 | if ($profileBackgroundColor == '' && $profileTextColor == '' && $profileLinkColor == '' && $profileSidebarFillColor == '' |
| 1976 | 2277 | && $profileSidebarBorderColor == '' |
| 1977 | - ) throw new TwitterException('Specify a profileBackgroundColor, profileTextColor, profileLinkColor, profileSidebarFillColor or a profileSidebarBorderColor.'); |
|
| 2278 | + ) { |
|
| 2279 | + throw new TwitterException('Specify a profileBackgroundColor, profileTextColor, profileLinkColor, profileSidebarFillColor or a profileSidebarBorderColor.'); |
|
| 2280 | + } |
|
| 1978 | 2281 | |
| 1979 | 2282 | // build parameters |
| 1980 | - if ($profileBackgroundColor != null) $parameters['profile_background_color'] = (string)$profileBackgroundColor; |
|
| 1981 | - if ($profileTextColor != null) $parameters['profile_text_color'] = (string)$profileTextColor; |
|
| 1982 | - if ($profileLinkColor != null) $parameters['profile_link_color'] = (string)$profileLinkColor; |
|
| 1983 | - if ($profileSidebarFillColor != null) $parameters['profile_sidebar_fill_color'] = (string)$profileSidebarFillColor; |
|
| 1984 | - if ($profileSidebarBorderColor != null) $parameters['profile_sidebar_border_color'] = (string)$profileSidebarBorderColor; |
|
| 2283 | + if ($profileBackgroundColor != null) { |
|
| 2284 | + $parameters['profile_background_color'] = (string)$profileBackgroundColor; |
|
| 2285 | + } |
|
| 2286 | + if ($profileTextColor != null) { |
|
| 2287 | + $parameters['profile_text_color'] = (string)$profileTextColor; |
|
| 2288 | + } |
|
| 2289 | + if ($profileLinkColor != null) { |
|
| 2290 | + $parameters['profile_link_color'] = (string)$profileLinkColor; |
|
| 2291 | + } |
|
| 2292 | + if ($profileSidebarFillColor != null) { |
|
| 2293 | + $parameters['profile_sidebar_fill_color'] = (string)$profileSidebarFillColor; |
|
| 2294 | + } |
|
| 2295 | + if ($profileSidebarBorderColor != null) { |
|
| 2296 | + $parameters['profile_sidebar_border_color'] = (string)$profileSidebarBorderColor; |
|
| 2297 | + } |
|
| 1985 | 2298 | |
| 1986 | 2299 | // make the call |
| 1987 | 2300 | return (array)$this->doCall('account/update_profile_colors.json', $parameters, true, 'POST'); |
@@ -2000,7 +2313,9 @@ discard block |
||
| 2000 | 2313 | throw new TwitterException('Not implemented'); |
| 2001 | 2314 | |
| 2002 | 2315 | // validate |
| 2003 | - if (!file_exists($image)) throw new TwitterException('Image (' . $image . ') doesn\'t exists.'); |
|
| 2316 | + if (!file_exists($image)) { |
|
| 2317 | + throw new TwitterException('Image (' . $image . ') doesn\'t exists.'); |
|
| 2318 | + } |
|
| 2004 | 2319 | |
| 2005 | 2320 | // make the call |
| 2006 | 2321 | return (array)$this->doCall('account/update_profile_image.json', null, true, 'POST', $image); |
@@ -2020,10 +2335,14 @@ discard block |
||
| 2020 | 2335 | throw new TwitterException('Not implemented'); |
| 2021 | 2336 | |
| 2022 | 2337 | // validate |
| 2023 | - if (!file_exists($image)) throw new TwitterException('Image (' . $image . ') doesn\'t exists.'); |
|
| 2338 | + if (!file_exists($image)) { |
|
| 2339 | + throw new TwitterException('Image (' . $image . ') doesn\'t exists.'); |
|
| 2340 | + } |
|
| 2024 | 2341 | |
| 2025 | 2342 | // build parameters |
| 2026 | - if ($tile) $parameters['tile'] = 'true'; |
|
| 2343 | + if ($tile) { |
|
| 2344 | + $parameters['tile'] = 'true'; |
|
| 2345 | + } |
|
| 2027 | 2346 | |
| 2028 | 2347 | // make the call |
| 2029 | 2348 | return (array)$this->doCall('account/update_profile_background_image.json', $parameters, true, 'POST', $image); |
@@ -2042,10 +2361,18 @@ discard block |
||
| 2042 | 2361 | { |
| 2043 | 2362 | // build parameters |
| 2044 | 2363 | $parameters = null; |
| 2045 | - if ($name != null) $parameters['name'] = (string)$name; |
|
| 2046 | - if ($url != null) $parameters['url'] = (string)$url; |
|
| 2047 | - if ($location != null) $parameters['location'] = (string)$location; |
|
| 2048 | - if ($description != null) $parameters['description'] = (string)$description; |
|
| 2364 | + if ($name != null) { |
|
| 2365 | + $parameters['name'] = (string)$name; |
|
| 2366 | + } |
|
| 2367 | + if ($url != null) { |
|
| 2368 | + $parameters['url'] = (string)$url; |
|
| 2369 | + } |
|
| 2370 | + if ($location != null) { |
|
| 2371 | + $parameters['location'] = (string)$location; |
|
| 2372 | + } |
|
| 2373 | + if ($description != null) { |
|
| 2374 | + $parameters['description'] = (string)$description; |
|
| 2375 | + } |
|
| 2049 | 2376 | |
| 2050 | 2377 | // make the call |
| 2051 | 2378 | return (array)$this->doCall('account/update_profile.json', $parameters, true, 'POST'); |
@@ -2064,8 +2391,12 @@ discard block |
||
| 2064 | 2391 | { |
| 2065 | 2392 | // build parameters |
| 2066 | 2393 | $parameters = null; |
| 2067 | - if ($id != null) $parameters['id'] = (string)$id; |
|
| 2068 | - if ($page != null) $parameters['page'] = (int)$page; |
|
| 2394 | + if ($id != null) { |
|
| 2395 | + $parameters['id'] = (string)$id; |
|
| 2396 | + } |
|
| 2397 | + if ($page != null) { |
|
| 2398 | + $parameters['page'] = (int)$page; |
|
| 2399 | + } |
|
| 2069 | 2400 | |
| 2070 | 2401 | // make the call |
| 2071 | 2402 | return (array)$this->doCall('favorites.json', $parameters, true); |
@@ -2113,12 +2444,20 @@ discard block |
||
| 2113 | 2444 | public function notificationsFollow($id = null, $userId = null, $screenName = null) |
| 2114 | 2445 | { |
| 2115 | 2446 | // validate |
| 2116 | - if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2447 | + if ($id == '' && $userId == '' && $screenName == '') { |
|
| 2448 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2449 | + } |
|
| 2117 | 2450 | |
| 2118 | 2451 | // build parameters |
| 2119 | - if ($id != null) $parameters['id'] = (string)$id; |
|
| 2120 | - if ($userId != null) $parameters['user_id'] = (string)$userId; |
|
| 2121 | - if ($screenName != null) $parameters['screen_name'] = (string)$screenName; |
|
| 2452 | + if ($id != null) { |
|
| 2453 | + $parameters['id'] = (string)$id; |
|
| 2454 | + } |
|
| 2455 | + if ($userId != null) { |
|
| 2456 | + $parameters['user_id'] = (string)$userId; |
|
| 2457 | + } |
|
| 2458 | + if ($screenName != null) { |
|
| 2459 | + $parameters['screen_name'] = (string)$screenName; |
|
| 2460 | + } |
|
| 2122 | 2461 | |
| 2123 | 2462 | // make the call |
| 2124 | 2463 | return (array)$this->doCall('notifications/follow.json', $parameters, true, 'POST'); |
@@ -2140,12 +2479,20 @@ discard block |
||
| 2140 | 2479 | public function notificationsLeave($id = null, $userId = null, $screenName = null) |
| 2141 | 2480 | { |
| 2142 | 2481 | // validate |
| 2143 | - if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2482 | + if ($id == '' && $userId == '' && $screenName == '') { |
|
| 2483 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2484 | + } |
|
| 2144 | 2485 | |
| 2145 | 2486 | // build parameters |
| 2146 | - if ($id != null) $parameters['id'] = (string)$id; |
|
| 2147 | - if ($userId != null) $parameters['user_id'] = (string)$userId; |
|
| 2148 | - if ($screenName != null) $parameters['screen_name'] = (string)$screenName; |
|
| 2487 | + if ($id != null) { |
|
| 2488 | + $parameters['id'] = (string)$id; |
|
| 2489 | + } |
|
| 2490 | + if ($userId != null) { |
|
| 2491 | + $parameters['user_id'] = (string)$userId; |
|
| 2492 | + } |
|
| 2493 | + if ($screenName != null) { |
|
| 2494 | + $parameters['screen_name'] = (string)$screenName; |
|
| 2495 | + } |
|
| 2149 | 2496 | |
| 2150 | 2497 | // make the call |
| 2151 | 2498 | return (array)$this->doCall('notifications/leave.json', $parameters, true, 'POST'); |
@@ -2169,12 +2516,20 @@ discard block |
||
| 2169 | 2516 | public function blocksCreate($id = null, $userId = null, $screenName = null) |
| 2170 | 2517 | { |
| 2171 | 2518 | // validate |
| 2172 | - if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2519 | + if ($id == '' && $userId == '' && $screenName == '') { |
|
| 2520 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2521 | + } |
|
| 2173 | 2522 | |
| 2174 | 2523 | // build parameters |
| 2175 | - if ($id != null) $parameters['id'] = (string)$id; |
|
| 2176 | - if ($userId != null) $parameters['user_id'] = (string)$userId; |
|
| 2177 | - if ($screenName != null) $parameters['screen_name'] = (string)$screenName; |
|
| 2524 | + if ($id != null) { |
|
| 2525 | + $parameters['id'] = (string)$id; |
|
| 2526 | + } |
|
| 2527 | + if ($userId != null) { |
|
| 2528 | + $parameters['user_id'] = (string)$userId; |
|
| 2529 | + } |
|
| 2530 | + if ($screenName != null) { |
|
| 2531 | + $parameters['screen_name'] = (string)$screenName; |
|
| 2532 | + } |
|
| 2178 | 2533 | |
| 2179 | 2534 | // make the call |
| 2180 | 2535 | return (array)$this->doCall('blocks/create.json', $parameters, true, 'POST'); |
@@ -2196,12 +2551,20 @@ discard block |
||
| 2196 | 2551 | public function blocksDestroy($id = null, $userId = null, $screenName = null) |
| 2197 | 2552 | { |
| 2198 | 2553 | // validate |
| 2199 | - if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2554 | + if ($id == '' && $userId == '' && $screenName == '') { |
|
| 2555 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2556 | + } |
|
| 2200 | 2557 | |
| 2201 | 2558 | // build parameters |
| 2202 | - if ($id != null) $parameters['id'] = (string)$id; |
|
| 2203 | - if ($userId != null) $parameters['user_id'] = (string)$userId; |
|
| 2204 | - if ($screenName != null) $parameters['screen_name'] = (string)$screenName; |
|
| 2559 | + if ($id != null) { |
|
| 2560 | + $parameters['id'] = (string)$id; |
|
| 2561 | + } |
|
| 2562 | + if ($userId != null) { |
|
| 2563 | + $parameters['user_id'] = (string)$userId; |
|
| 2564 | + } |
|
| 2565 | + if ($screenName != null) { |
|
| 2566 | + $parameters['screen_name'] = (string)$screenName; |
|
| 2567 | + } |
|
| 2205 | 2568 | |
| 2206 | 2569 | // make the call |
| 2207 | 2570 | return (array)$this->doCall('blocks/destroy.json', $parameters, true, 'POST'); |
@@ -2223,12 +2586,20 @@ discard block |
||
| 2223 | 2586 | public function blocksExists($id = null, $userId = null, $screenName = null) |
| 2224 | 2587 | { |
| 2225 | 2588 | // validate |
| 2226 | - if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2589 | + if ($id == '' && $userId == '' && $screenName == '') { |
|
| 2590 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2591 | + } |
|
| 2227 | 2592 | |
| 2228 | 2593 | // build parameters |
| 2229 | - if ($id != null) $parameters['id'] = (string)$id; |
|
| 2230 | - if ($userId != null) $parameters['user_id'] = (string)$userId; |
|
| 2231 | - if ($screenName != null) $parameters['screen_name'] = (string)$screenName; |
|
| 2594 | + if ($id != null) { |
|
| 2595 | + $parameters['id'] = (string)$id; |
|
| 2596 | + } |
|
| 2597 | + if ($userId != null) { |
|
| 2598 | + $parameters['user_id'] = (string)$userId; |
|
| 2599 | + } |
|
| 2600 | + if ($screenName != null) { |
|
| 2601 | + $parameters['screen_name'] = (string)$screenName; |
|
| 2602 | + } |
|
| 2232 | 2603 | |
| 2233 | 2604 | try { |
| 2234 | 2605 | // make the call |
@@ -2237,7 +2608,9 @@ discard block |
||
| 2237 | 2608 | catch (TwitterException $e) { |
| 2238 | 2609 | if ($e->getMessage() === 'You are not blocking this user.') { |
| 2239 | 2610 | return false; |
| 2240 | - } else throw $e; |
|
| 2611 | + } else { |
|
| 2612 | + throw $e; |
|
| 2613 | + } |
|
| 2241 | 2614 | } |
| 2242 | 2615 | } |
| 2243 | 2616 | |
@@ -2251,7 +2624,9 @@ discard block |
||
| 2251 | 2624 | { |
| 2252 | 2625 | // build parameters |
| 2253 | 2626 | $parameters = null; |
| 2254 | - if ($page != null) $parameters['page'] = (int)$page; |
|
| 2627 | + if ($page != null) { |
|
| 2628 | + $parameters['page'] = (int)$page; |
|
| 2629 | + } |
|
| 2255 | 2630 | |
| 2256 | 2631 | // make the call |
| 2257 | 2632 | return (array)$this->doCall('blocks/blocking.json', $parameters, true); |
@@ -2286,12 +2661,20 @@ discard block |
||
| 2286 | 2661 | public function reportSpam($id = null, $userId = null, $screenName = null) |
| 2287 | 2662 | { |
| 2288 | 2663 | // validate |
| 2289 | - if ($id == '' && $userId == '' && $screenName == '') throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2664 | + if ($id == '' && $userId == '' && $screenName == '') { |
|
| 2665 | + throw new TwitterException('Specify an id or an userId or a screenName.'); |
|
| 2666 | + } |
|
| 2290 | 2667 | |
| 2291 | 2668 | // build parameters |
| 2292 | - if ($id != null) $parameters['id'] = (string)$id; |
|
| 2293 | - if ($userId != null) $parameters['user_id'] = (string)$userId; |
|
| 2294 | - if ($screenName != null) $parameters['screen_name'] = (string)$screenName; |
|
| 2669 | + if ($id != null) { |
|
| 2670 | + $parameters['id'] = (string)$id; |
|
| 2671 | + } |
|
| 2672 | + if ($userId != null) { |
|
| 2673 | + $parameters['user_id'] = (string)$userId; |
|
| 2674 | + } |
|
| 2675 | + if ($screenName != null) { |
|
| 2676 | + $parameters['screen_name'] = (string)$screenName; |
|
| 2677 | + } |
|
| 2295 | 2678 | |
| 2296 | 2679 | // make the call |
| 2297 | 2680 | return (array)$this->doCall('report_spam.json', $parameters, true, 'POST'); |
@@ -2369,17 +2752,25 @@ discard block |
||
| 2369 | 2752 | $parameters = array(); |
| 2370 | 2753 | |
| 2371 | 2754 | // set callback |
| 2372 | - if ($callbackURL != null) $parameters['oauth_callback'] = (string)$callbackURL; |
|
| 2755 | + if ($callbackURL != null) { |
|
| 2756 | + $parameters['oauth_callback'] = (string)$callbackURL; |
|
| 2757 | + } |
|
| 2373 | 2758 | |
| 2374 | 2759 | // make the call |
| 2375 | 2760 | $response = $this->doOAuthCall('request_token', $parameters); |
| 2376 | 2761 | |
| 2377 | 2762 | // validate |
| 2378 | - if (!isset($response['oauth_token'], $response['oauth_token_secret'])) throw new TwitterException(implode(', ', array_keys($response))); |
|
| 2763 | + if (!isset($response['oauth_token'], $response['oauth_token_secret'])) { |
|
| 2764 | + throw new TwitterException(implode(', ', array_keys($response))); |
|
| 2765 | + } |
|
| 2379 | 2766 | |
| 2380 | 2767 | // set some properties |
| 2381 | - if (isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']); |
|
| 2382 | - if (isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']); |
|
| 2768 | + if (isset($response['oauth_token'])) { |
|
| 2769 | + $this->setOAuthToken($response['oauth_token']); |
|
| 2770 | + } |
|
| 2771 | + if (isset($response['oauth_token_secret'])) { |
|
| 2772 | + $this->setOAuthTokenSecret($response['oauth_token_secret']); |
|
| 2773 | + } |
|
| 2383 | 2774 | |
| 2384 | 2775 | // return |
| 2385 | 2776 | return $response; |
@@ -2404,8 +2795,12 @@ discard block |
||
| 2404 | 2795 | $response = $this->doOAuthCall('access_token', $parameters); |
| 2405 | 2796 | |
| 2406 | 2797 | // set some properties |
| 2407 | - if (isset($response['oauth_token'])) $this->setOAuthToken($response['oauth_token']); |
|
| 2408 | - if (isset($response['oauth_token_secret'])) $this->setOAuthTokenSecret($response['oauth_token_secret']); |
|
| 2798 | + if (isset($response['oauth_token'])) { |
|
| 2799 | + $this->setOAuthToken($response['oauth_token']); |
|
| 2800 | + } |
|
| 2801 | + if (isset($response['oauth_token_secret'])) { |
|
| 2802 | + $this->setOAuthTokenSecret($response['oauth_token_secret']); |
|
| 2803 | + } |
|
| 2409 | 2804 | |
| 2410 | 2805 | // return |
| 2411 | 2806 | return $response; |
@@ -2448,8 +2843,12 @@ discard block |
||
| 2448 | 2843 | { |
| 2449 | 2844 | // build parameters |
| 2450 | 2845 | $parameters = null; |
| 2451 | - if ($lat != null) $parameters['lat_for_trends'] = (float)$lat; |
|
| 2452 | - if ($long != null) $parameters['long_for_trends'] = (float)$long; |
|
| 2846 | + if ($lat != null) { |
|
| 2847 | + $parameters['lat_for_trends'] = (float)$lat; |
|
| 2848 | + } |
|
| 2849 | + if ($long != null) { |
|
| 2850 | + $parameters['long_for_trends'] = (float)$long; |
|
| 2851 | + } |
|
| 2453 | 2852 | |
| 2454 | 2853 | // make the call |
| 2455 | 2854 | return (array)$this->doCall('trends/available.json', $parameters); |
@@ -2490,9 +2889,15 @@ discard block |
||
| 2490 | 2889 | // build parameters |
| 2491 | 2890 | $parameters['lat'] = (float)$lat; |
| 2492 | 2891 | $parameters['long'] = (float)$long; |
| 2493 | - if ($accuracy != null) $parameters['accuracy'] = (string)$accuracy; |
|
| 2494 | - if ($granularity != null) $parameters['granularity'] = (string)$granularity; |
|
| 2495 | - if ($maxResults != null) $parameters['max_results'] = (int)$maxResults; |
|
| 2892 | + if ($accuracy != null) { |
|
| 2893 | + $parameters['accuracy'] = (string)$accuracy; |
|
| 2894 | + } |
|
| 2895 | + if ($granularity != null) { |
|
| 2896 | + $parameters['granularity'] = (string)$granularity; |
|
| 2897 | + } |
|
| 2898 | + if ($maxResults != null) { |
|
| 2899 | + $parameters['max_results'] = (int)$maxResults; |
|
| 2900 | + } |
|
| 2496 | 2901 | |
| 2497 | 2902 | // make the call |
| 2498 | 2903 | return (array)$this->doCall('geo/reverse_geocode.json', $parameters); |
@@ -2509,7 +2914,9 @@ discard block |
||
| 2509 | 2914 | { |
| 2510 | 2915 | // build parameters |
| 2511 | 2916 | $parameters = null; |
| 2512 | - if ($placeId != null) $parameters['place_id'] = (string)$placeId; |
|
| 2917 | + if ($placeId != null) { |
|
| 2918 | + $parameters['place_id'] = (string)$placeId; |
|
| 2919 | + } |
|
| 2513 | 2920 | |
| 2514 | 2921 | // make the call |
| 2515 | 2922 | return (array)$this->doCall('geo/id/' . (string)$id . '.json', $parameters); |