Facebook Graph API Read Followers Count
Asked Answered
B

6

15

Using the Facebook Graph API or some other means, is there a currently-available way to get a user's follower count? You'd think it would be a simple readable metric field at the user level, but after hours of searching, I cannot find such a field.

I know Facebook considers the concept of followers to be valid, because they have a working "edge" for it with their web interface, https://www.facebook.com/user_name/followers as well as listing the account on the user's main page (see image example below).

Certainly it seems the capability to read, or at least derive, the followers count existed previously in the form of reading the "subscribers" list for a user, but that's now obsolete. An alternative method seems to have been to use FQL to query the data. This method is now also obsolete. And there are stackoverflow questions about it, a good example is here, but they seem to relate to previous capabilities no longer available.

Example from Facebook user page

Bruner answered 1/6, 2016 at 15:11 Comment(0)
C
10

According to the docs, there is no possibility to get the follower count: https://developers.facebook.com/docs/graph-api/reference/user

The subscribers endpoint was removed with v2.0 already: https://developers.facebook.com/docs/apps/changelog#v2_0

Other threads about the same topic:

Collywobbles answered 1/6, 2016 at 15:39 Comment(3)
I agree about the endpoint. I've looked several times at the API reference page you link to, but I don't see it explicitly stated that there's "no possibility" as you say. Not that I doubt you, but if it's not too much trouble, could you quote me specifically where it says that?Bruner
if something is not even in the user table, you can be pretty sure it does not exist ;) - this has been discussed some times already though, i have added the first links i could find in my answer.Collywobbles
why the downvote? please add a comment so i can improve my answer if needed.Collywobbles
S
2

If you have an access_token, you can call {profile-id}/insights/page_fans_country and retrieve the number of people who like the page aggregated by country. This works for any public profile.

https://graph.facebook.com/{profile-id}/insights/page_fans_country?access_token={access-token}

You could then sum up the countries to get the total number of followers. If you need to retrieve followers for your own profile, you can call page_fans which provides the total number of people who have liked your page.

Shift answered 20/2, 2017 at 3:36 Comment(3)
Sum up the values from one of the arrays containing 45 countries. As close as you can get it seems since page_fans returns nothing.Creditor
insights/page_fans actually returns valid results for me on a new integration using the php sdkWhooper
This doesn't work for Users. Error: (#100) Tried accessing nonexisting field (insights) on node type (User)Salmonella
W
2

You can use fan_count:

{
  "id": "235014179868339",
  "name": "Zoella",
  "fan_count": 2647287
}

Facebook Graph API Explorer

Wheaten answered 6/7, 2017 at 20:15 Comment(3)
This only works for facebook pages not individual profiles.Reverse
Warning on fan_count for Page objects: I just a few days figuring out it returns the number of people who like the page. Not the number who follow it. I don't know if it's the same for User objects. Watch out in case it's the same.Recitative
fan_count description from the Page object's metadata: "The number of users who like the Page. For Global Pages this is the count for all Pages across the brand". fan_count is not a followers count.Desideratum
S
1

This is an updated and working code snippet which can be used to retrieve Facebook like count of a specific page. To use this code snippet you’ll need a Facebook App ID and Secret Key. This use latest 2.8 API version method.

enter image description here

Step 1:

Go to https://developers.facebook.com/ login with your facebook account. If you don’t have one you have to create one.

Step 2:

Created an app from facebook developer.

Step3:

You have to get App ID and App Secret from app you created.

enter image description here

Step 4:

PHP Code to get facebook like count of a page.

<?php
function fbLikeCount($id,$appid,$appsecret){
  $json_url ='https://graph.facebook.com/'.$id.'?access_token='.$appid.'|'.$appsecret.'&fields=fan_count';
  $json = file_get_contents($json_url);
  $json_output = json_decode($json);
  //Extract the likes count from the JSON object
  if($json_output->fan_count){
    return $fan_count = $json_output->fan_count;
  }else{
    return 0;
  }
}
echo fbLikeCount('coregenie','___APPID___','___APPSECRET___');
?>

Please edit your page name , app id, app secret.

This method is working. Tested on 19/12/2017

Samaveda answered 19/12, 2017 at 11:36 Comment(2)
just a guess, because it happened in the same time: did you downvote my answer? because it is 100% correct, the question was if there is a way to get the followers of a user profile and that is definitely not possible. what you describe in length is about LIKES, not FOLLOWERS.Collywobbles
fan_count was added in v2.6 and according to the docs, it returns the total likes. developers.facebook.com/docs/graph-api/reference/pageCloying
P
1

What I did to see if these metrics exist in the api was to check the requests made by Facebook when creating a report, I got the following metrics:

metric=page_daily_follows,page_daily_follows_unique,page_daily_unfollows,page_daily_unfollows_unique,page_follows

It should be clarified that these are not in the documentation, I hope it helps.

Phan answered 22/9, 2020 at 17:23 Comment(0)
H
0

You can use metric page_follows to get the follower count, I used it and it was correctly.

Hearn answered 13/6, 2023 at 6:29 Comment(1)
Your answer could be improved by providing an example of the solution and how it helps the OP.Bowknot

© 2022 - 2024 — McMap. All rights reserved.