borobos
borobos

Reputation: 21

FaceBook API for friends count

There is the question about fetching count of user friends via FaceBook API.

I want to get the number of friends only have USER_ID of the any facebook user. As I know I can get it using FQL like:

SELECT friend_count FROM user WHERE uid = X

But for some users this value is null or there is no value. Please advice is there another way to get this value?

Upvotes: 1

Views: 3938

Answers (2)

vaibhav kulkarni
vaibhav kulkarni

Reputation: 1800

You just check the following link. You need to generate token (by clicking on Get Token you will get it) with data you want from facebook API, need to select friends option to get the friend count.

https://developers.facebook.com/tools/explorer/?method=GET&path=me%3Ffields%3Did%2Cname%2Cfriends&version=v2.8

FB.api(
  '/me',
  'GET',
  {"fields":"id,name,friends,link,email,gender,picture,first_name,last_name,cover"},
  function(response) {
      // Insert your code here
  }
);

after executing this you will get this in response as

{
  "id": "XXXXXXXXXX",
  "name": "Test test",
  "friends": {
    "data": [
    ],
    "summary": {
      "total_count": 14
    }
  }
}

total_count will be your friend count

Upvotes: 0

sbaker
sbaker

Reputation: 428

That user might be keeping that information private. In that case, you cannot fetch that information.

Upvotes: 1

Related Questions