Using the Instagram API to get ALL followers

Viewed 24034

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...

5 Answers

if the APIs are optional

using the mobile version of twitter you can extract a full list of a followers for a designed target using a very simple bash script

the sleep time must me chosen carefully to avoid temporary ip block

the script can be executed by :

./scriptname.sh targetusername

content

   #!/bin/bash

    counter=1 

    wget --load-cookies ./twitter.cookies -O - "https://mobile.twitter.com/$1/followers?" > page 


    until [ $counter = 0 ]; do

    cat page | grep -i "@" | grep -vi "fullname" | grep -vi "$1" | awk -F">" '{print $5}' | awk -F"<" '{print $1}' >> userlist

    nextpage=$(cat page | grep -i "cursor" | awk -F'"' '{print $4}')

    wget --load-cookies twitter.cookies -O - "https://mobile.twitter.com/$nextpage" > page

    if [ -z $nextpage ]; then 

    exit 0

    fi

    sleep 5 

    done

it creates a file "userlist" including all usernames that follows the designed target one by line

PS: a cookies file filled with your credentials is necessary to wget to authenticate the requests

I personally suggest to use Wizboost for instagram automation. And the reason is that I have used this tool and my experience is amazing. It gave me a lot of followers. Now you don’t need to invest time in competing with other Instagram accounts as Wizboost has got your back for this, in fact for everything. You don’t need to do anything you can just relax and Wizboost will get you followers, likes and comments. And you can also schedule your posts too. So easy to use and still got lots of potential. I just love Wizboost for all the services it has.

Related