Created
October 1, 2012 19:16
-
-
Save agustinhaller/3813810 to your computer and use it in GitHub Desktop.
cron update fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This function will get only the latest 5000 followers of certain user and update them in the db | |
| // First we ask Twitter for fresh followers | |
| $fresh_followers = array(); | |
| $tmhOAuth = initTmhOAuth($organizer_username); | |
| $tmhOAuth->request('GET', $tmhOAuth->url('1/followers/ids'), array( | |
| 'stringify_ids' => true, | |
| 'screen_name' => $organizer_username | |
| )); | |
| if($tmhOAuth->response['code'] == 200) | |
| { | |
| $data = json_decode($tmhOAuth->response['response'], true); | |
| $fresh_followers = $data['ids']; | |
| } | |
| else// Twitter call error | |
| { | |
| $tw_response = $tmhOAuth->response['response']; | |
| $log_text = "Twitter call error when getting followers in function 'getTwitterFollowers'"; | |
| $log_data = array("case" =>"TWITTER CALL ERROR", | |
| "exception"=>"", | |
| "response"=>$log_text.$tw_response); | |
| logError($log_data); | |
| } | |
| $tw_manager = TwitterAPICallManager::getManager(); | |
| $tw_manager->newCall(); | |
| // If we get something from twitter, then proceed | |
| if(count($fresh_followers) > 0) | |
| { | |
| // Lets get stored followers in db | |
| $db_tw_followers = getLastFollowersFromRecord($organizer_username); | |
| if(count($db_tw_followers)>0) | |
| { | |
| // Now we need to get new followers for that organizer | |
| $new_followers = array_diff($fresh_followers, $db_tw_followers); | |
| // Now that we have new followers, we need to store them | |
| processNewFollowers($new_followers, $organizer_username); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment