@@ -93,6 +93,9 @@ |
||
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | + /** |
|
| 97 | + * @return boolean|string |
|
| 98 | + */ |
|
| 96 | 99 | private function findNext($haystack) |
| 97 | 100 | { |
| 98 | 101 | $max_id_next = false; |
@@ -64,19 +64,19 @@ discard block |
||
| 64 | 64 | 'count' => 100, // increase limit to REST API maximum: 100. |
| 65 | 65 | ); |
| 66 | 66 | |
| 67 | - if($max_id) { |
|
| 67 | + if ($max_id) { |
|
| 68 | 68 | $params['max_id'] = $max_id; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if($this->oauth_token && $this->oauth_secret) { |
|
| 71 | + if ($this->oauth_token && $this->oauth_secret) { |
|
| 72 | 72 | $connection = $this->getConnectionWithAccessToken($this->oauth_token, $this->oauth_secret); |
| 73 | 73 | $content = $connection->get("search/tweets", $params); |
| 74 | 74 | |
| 75 | 75 | $this->count += count($content->statuses); |
| 76 | 76 | |
| 77 | 77 | // paginated search, are there any 'next' results? |
| 78 | - if(isset($content->search_metadata->next_results)) { |
|
| 79 | - if($max_id_next = $this->findNext($content->search_metadata->next_results)) { |
|
| 78 | + if (isset($content->search_metadata->next_results)) { |
|
| 79 | + if ($max_id_next = $this->findNext($content->search_metadata->next_results)) { |
|
| 80 | 80 | $this->getShares($url, $max_id_next); |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | private function getConnectionWithAccessToken($oauth_token, $oauth_secret) |
| 89 | 89 | { |
| 90 | - if($this->consumer_key && $this->consumer_secret) { |
|
| 90 | + if ($this->consumer_key && $this->consumer_secret) { |
|
| 91 | 91 | $connection = new TwitterOAuth($this->consumer_key, $this->consumer_secret, $oauth_token, $oauth_secret); |
| 92 | 92 | return $connection; |
| 93 | 93 | } |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | $max_id_next = false; |
| 99 | 99 | $max_id_search = explode('?', $haystack); |
| 100 | 100 | |
| 101 | - if(isset($max_id_search[1])) { |
|
| 101 | + if (isset($max_id_search[1])) { |
|
| 102 | 102 | $max_id_search = explode('&', $max_id_search[1]); |
| 103 | 103 | |
| 104 | 104 | foreach ($max_id_search as $key => $value) { |
| 105 | - if(strpos($value, 'max_id=') !== false) { |
|
| 105 | + if (strpos($value, 'max_id=') !== false) { |
|
| 106 | 106 | $max_id_found = explode('=', $value); |
| 107 | - if(isset($max_id_found[1])) { |
|
| 107 | + if (isset($max_id_found[1])) { |
|
| 108 | 108 | $max_id_next = $max_id_found[1]; |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -25,9 +25,9 @@ |
||
| 25 | 25 | $socialShare->registerProvider(new Tumblr()); |
| 26 | 26 | |
| 27 | 27 | // Create an app here: https://apps.twitter.com/ |
| 28 | -$twitterConsumerKey = '__set_to_your_app_key__'; // app / Keys and Access Tokens, use "Consumer Key" |
|
| 29 | -$twitterConsumerSecret = '__set_to_your_app_secret__'; // app / Keys and Access Tokens, use "Consumer Secret" |
|
| 30 | -$twitterOauthToken = '__set_to_your_access_token__'; // app / Keys and Access Tokens, use "Access Token" (generate access token and secret) |
|
| 28 | +$twitterConsumerKey = '__set_to_your_app_key__'; // app / Keys and Access Tokens, use "Consumer Key" |
|
| 29 | +$twitterConsumerSecret = '__set_to_your_app_secret__'; // app / Keys and Access Tokens, use "Consumer Secret" |
|
| 30 | +$twitterOauthToken = '__set_to_your_access_token__'; // app / Keys and Access Tokens, use "Access Token" (generate access token and secret) |
|
| 31 | 31 | $twitterOauthSecret = '__set_to_your_access_token_secret__'; // app / Keys and Access Tokens, use "Access Token Secret" (generate access token and secret) |
| 32 | 32 | |
| 33 | 33 | $socialShare->registerProvider(new Twitter($twitterConsumerKey, $twitterConsumerSecret, $twitterOauthToken, $twitterOauthSecret)); |