Created
September 26, 2010 21:53
-
-
Save abraham/598349 to your computer and use it in GitHub Desktop.
Quick script to get all of the followers for Twitter users.
This file contains 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
<?php | |
// Require the TwitterOAuth library. http://github.com/abraham/twitteroauth | |
require_once('twitteroauth/twitteroauth.php'); | |
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_SECRET); | |
// Empty array that will be used to store followers. | |
$profiles = array(); | |
// Get the ids of all followers. | |
$ids = $connection->get('followers/ids'); | |
// Chunk the ids in to arrays of 100. | |
$ids_arrays = array_chunk($ids, 100); | |
// Loop through each array of 100 ids. | |
foreach($ids_arrays as $implode) { | |
// Perform a lookup for each chunk of 100 ids. | |
$results = $connection->get('users/lookup', array('user_id' => implode(',', $implode))); | |
// Loop through each profile result. | |
foreach($results as $profile) { | |
// Use screen_name as key for $profiles array. | |
$profiles[$profile->screen_name] = $profile; | |
} | |
} | |
// Array of user objects. | |
var_dump($profiles); |
Can this will come to 'rate limit exceeded' error of twitter api or not ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i want to get all the followers of users and want to download list in csv or any other formet, so this will help or not?