Search code examples
phpinstagraminstagram-api

Display Who Follows You on Instagram


I am trying to create a simple script that displays who a user follows and if that person follows them back or not. Is there a way to fetch this information with Instagram API?


Solution

  • These are the relevant Instagram API docs you should refer to for specifics.

    As a rough overview: you will need to register a developer account, create an app, and authorize that app to receive an access token. Once you have that, something like this will do what you want:

    $userId = "self";
    
    $url = "https://api.instagram.com/v1/users/$user/followed-by?access_token=$accessToken";
    
    $response = json_decode(file_get_contents($url));
    $followers = $response->data;
    

    Of course you can also use cURL or Guzzle instead.

    Note: to get a user's follower list that user must authorize your application with scope=follower_list to be granted this permission.