Sophia Martin
Sophia Martin

Reputation: 51

How to get instagram new followers by using API in php?

i need to get instagram new followers using instagram API. I am able to get total friends but not able to get NEW followers. I have to get NEW followers.

$obj = new Instagram\Instagram;
$obj->setAccessToken($sKey1);
$_SESSION['Inst_'.$keys['AppKey']] = $obj;  
$current_user = $_SESSION['Inst_'.$keys['AppKey']]->getCurrentUser();
$follows = $current_user->getFollows( isset( $_GET['follows_cursor'] ) ? array( 'cursor' => $_GET['follows_cursor'] ) : null );
$follows_count = $current_user->getFollowsCount();

How to get new followers not total followers?

Upvotes: 0

Views: 1834

Answers (2)

As Rahul said, i haven´t find a clean way to detect if someone has follow my instagram account, but the algorithm recommended wouldn't work as expected.

I would recommend to store a list of followers, then (lets suppose 5 mins later) ask the api for a new list of followers and compare if you have someone new. Because, only by checking the number of followers you would be missing new followers, a good example would be if at the same time someone follows and another one unfollows. Hope this helps. I dont know about PHP but PYTHON has a nice built in function to compare lists.

Upvotes: 1

Rahul Mohanraj
Rahul Mohanraj

Reputation: 61

I think there is no direct method but you can try this algorithm.

  1. Store number of followers a user has.
  2. Now when you check for new followers find the difference in number of followers with current and saved number.
  3. Let's say if 'three' is the difference then, in the API Endpoint get the first three followers of the user. And they are the new followers.

Upvotes: 0

Related Questions