Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the Instagram API to get ALL followers

I'm using the Instagram API to get the number of people who follow a given account as follows.

$follow_info = file_get_contents('https://api.instagram.com/v1/users/477644454/followed-by?access_token=ACESS_TOKEN&count=-1');
$follow_info = @json_decode($follow_info, true);

This returns a set of 50 results. They do have a next_url key in the array, but it becomes time consuming to keep on going to the next page of followers when dealing with tens of thousands.

I read on StackOverflow that setting the count parameter to -1 would return the entire set. But, it doesn't seem to...

like image 646
Lance Avatar asked Dec 17 '13 20:12

Lance


People also ask

How can I get a full list of followers on Instagram?

Option 1: The Manual Option. This first option is easy: just go to your profile on Instagram – the URL www.instagram.com/yourusername – and click on the “# followers” label up a the top. This will pop up a lightbox that will show you several pieces of information. The username of each person who follows you.

Does Instagram API still work?

On the 29th of June, 2020, Instagram will stop using the old API (“Basic Permission”) to display photos from personal Instagram accounts to widgets. 3rd party apps using this, current API will no longer be able to display photos from your account if they don't switch to the new API after this date.

What data can I get from Instagram API?

The Instagram Basic Display API allows users of your app to get basic profile information, photos, and videos in their Instagram accounts. The API can be used to access any type of Instagram account but only provides read-access to basic data.


1 Answers

Instagram limits the number of results returned in their API for all sorts of endpoints, and they change these limits arbitrarily, without warning, presumably to handle server load.

Several similar threads exist:

  • Instagram API not fufilling count parameter
  • Displaying more than 20 photos in instagram API
  • Instagram API: How to get all user media? (see comments on answer too, -1 returns 1 less result).
  • 350 Request Limit for Instagram API
  • Instagram API: How to get all user media?

In short, you won't be able to increase the maximum returned rows, and you'll be stuck paginating.

like image 117
brandonscript Avatar answered Sep 29 '22 23:09

brandonscript