I tried this and even added a cursor but it would still retrieve only the first 100 followers.
<?php
$cursor = -1;
$account_from = 'username';
do
{
$json = file_get_contents('http://api.twitter.com/1/statuses/followers/' . $account_from .'.json?cursor=' . $cursor);
$accounts = json_decode($json);
foreach ($accounts->users as $account)
{
$a[] = $account->screen_name ;
}
$cursor = $accounts->next_cursor;
}
while ($cursor > 0);
foreach($a as $f) {
echo $f ;
}
?>
Is there a better and simpler way of doing it? Where am i going wrong? help please?
API docs state this request is deprecated:
This method is deprecated as it will only return information about users who have Tweeted recently. It is not a functional way to retrieve all of a users followers. Instead of using this method use a combination of GET followers/ids and GET users/lookup.
Use this API instead: https://dev.twitter.com/docs/api/1/get/followers/ids
There should be a property in your object called next_cursor
, as long as that's non-zero, keep doing the request again (specifying that cursor) until you get all the results.