Hii sometime is problem to get all twitter follower list via single code using cursor , as u can get error "rate limit has been exceeded"
i got into this problem so i figured out solution hope this might help you ,
put any question if u have confusion:
Index.php
<?php
ini_set('max_execution_time', 6000);
ini_set('memory_limit', '1024M');
ini_set('display_errors', 0);
error_reporting(0);
require_once('TwitterAPIExchange.php');
$settings = array(
'oauth_access_token' => "",
'oauth_access_token_secret' => "",
'consumer_key' => "",
'consumer_secret' => ""
);
$requestMethod = 'GET';
$url1="https://api.twitter.com/1.1/followers/ids.json";
$url2="https://api.twitter.com/1.1/users/lookup.json";
$sc_name = 'screenamehere';
$cursor = -1;
$profiles = array();
$getfield = '?screen_name=rocdamicforever&cursor='.$cursor;
$twitter = new TwitterAPIExchange($settings);
$ids = $twitter->setGetfield($getfield)->buildOauth($url1, $requestMethod)->performRequest();
$twitter_ids = json_decode($ids);
$allids = $twitter_ids->{'ids'};
if(!is_array($allids)) break;
$ids_arrays = array_chunk($allids, 100);
$k = 0;
foreach($ids_arrays as $implode) {
$user_ids=implode(',', $implode);
$getfield2 = '?user_id='.$user_ids;
$results = $twitter->setGetfield($getfield2)->buildOauth($url2, $requestMethod)->performRequest();
$finalresul = json_decode($results);
foreach($finalresul as $profile) {
$k++;
echo "<pre>";
//print_r($profile);
echo $profile->id.' '.$profile->name.' '.$profile->screen_name;
echo "</pre>";
echo '-------------------------------------<br>';
}
}
echo "Toatal Records ".$k;
TwitterAPIExchange.php (basically this file has been taken from github )
https://github.com/J7mbo/twitter-api-php/
Now what am i doing:
1: I first of all take all follower list from user screen name : url 1 (you can find it here 5000 at once)
2: then i use look up to get detail about list ids url2 (you can get detail about 100 ids in single request)
i got into this problem so i figured out solution hope this might help you ,
put any question if u have confusion:
Index.php
<?php
ini_set('max_execution_time', 6000);
ini_set('memory_limit', '1024M');
ini_set('display_errors', 0);
error_reporting(0);
require_once('TwitterAPIExchange.php');
$settings = array(
'oauth_access_token' => "",
'oauth_access_token_secret' => "",
'consumer_key' => "",
'consumer_secret' => ""
);
$requestMethod = 'GET';
$url1="https://api.twitter.com/1.1/followers/ids.json";
$url2="https://api.twitter.com/1.1/users/lookup.json";
$sc_name = 'screenamehere';
$cursor = -1;
$profiles = array();
$getfield = '?screen_name=rocdamicforever&cursor='.$cursor;
$twitter = new TwitterAPIExchange($settings);
$ids = $twitter->setGetfield($getfield)->buildOauth($url1, $requestMethod)->performRequest();
$twitter_ids = json_decode($ids);
$allids = $twitter_ids->{'ids'};
if(!is_array($allids)) break;
$ids_arrays = array_chunk($allids, 100);
$k = 0;
foreach($ids_arrays as $implode) {
$user_ids=implode(',', $implode);
$getfield2 = '?user_id='.$user_ids;
$results = $twitter->setGetfield($getfield2)->buildOauth($url2, $requestMethod)->performRequest();
$finalresul = json_decode($results);
foreach($finalresul as $profile) {
$k++;
echo "<pre>";
//print_r($profile);
echo $profile->id.' '.$profile->name.' '.$profile->screen_name;
echo "</pre>";
echo '-------------------------------------<br>';
}
}
echo "Toatal Records ".$k;
TwitterAPIExchange.php (basically this file has been taken from github )
https://github.com/J7mbo/twitter-api-php/
Now what am i doing:
1: I first of all take all follower list from user screen name : url 1 (you can find it here 5000 at once)
2: then i use look up to get detail about list ids url2 (you can get detail about 100 ids in single request)