Twitter API: Get Followers +99

11,817

Solution 1

You need to specify cursor parameter as described in the API documrnation. E.g. specify cursor=-1 to request the first page and then use a next_cursor value returned in the first response:

  http://twitter.com/statuses/followers/barackobama.xml?cursor=-1
  http://twitter.com/statuses/followers/barackobama.xml?cursor=1300794057949944903

Solution 2

<?php
$trends_url = "http://api.twitter.com/1/statuses/followers/fawadghafoor.json";
$ch       = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $trends_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curlout  = curl_exec($ch);
curl_close($ch);
$response = json_decode($curlout, true);

foreach($response as $friends){
      $thumb = $friends['profile_image_url'];
      $url   = $friends['screen_name'];
      $name  = $friends['name'];
?>                         
<a title="<?php echo $name;?>" href="http://www.twitter.com/<?php echo $url;?>"><img class="photo-img" src="<?php echo $thumb?>" border="0" alt="" width="40" /></a>
    <?php  }  ?>

Solution 3

Be sure you're using the right call. followers/ids gives you 5000 at a time (but it's just a list of ids). This call, too, uses the cursor to let you step through pages of users. You get a zero back when you have them all.

Solution 4

Twitter API restricts us to make api Call for method followers/ids is 15 requests per 15 minutes. If you make more than this api will give you an error message that Rate Limit Reached.

For more information of twitter API rate Limit Visit-https://dev.twitter.com/docs/rate-limiting/1.1 and https://dev.twitter.com/docs/rate-limiting/1.1/limits

Share:
11,817
tarnfeld
Author by

tarnfeld

Updated on June 16, 2022

Comments

  • tarnfeld
    tarnfeld almost 2 years

    Using the twitter API (and OAuth) if i was to call for the user followers, (statuses/followers) i would be returned only 99 results.

    Is there a way i can return 99, then call again starting at follower 100 then looping through this style of calling until the total number of followers has been returned?

    Or just return ALL followers?

  • Nosredna
    Nosredna over 14 years
    The total is 150 per hour. So he could get 100 people 150 times (or 5000 people 150 times, depending on the call he uses). This number is for the calls that don't need authorization. Calls that require authorization are tallied separately. You can request whitelisting for your app, but even that is not enough to go banging at the API willy-nilly, so if you expect a high-volume service, you need to do some caching.
  • Nosredna
    Nosredna over 14 years
    But you make a good point. There are many accounts with many more than 15,000 followers. You'll use up all your API hits at once with them.
  • tarnfeld
    tarnfeld over 14 years
    they are on a per OAuth user basis - if user_1 hits their limit.. they get errors, but user_2 will still be fine
  • Ben G
    Ben G over 11 years
    You get "Not authorized to use this endpoint" when you try these URLs.. I think they may have changed their API?
  • Mark Garcia
    Mark Garcia over 11 years
    Could you please add even the tiniest bit of explanation for your answer? Additional information on how for him to incorporate it to his code would also be good.