eyal_katz
eyal_katz

Reputation: 1131

Not getting the response.summary.total_count value in the Facebook API

I am using www.oauth.io with javascript to connect to Facebook.

I am trying to retrieve the number of friends for the person that logged in.

I understand that recently Facebook changed their policy and it is not easy to get the friend list. Digging deeper, it seems that they have another way to get the total number of friends, using this field in the /me/friends resuts: response.summary.total_count

Here are some links refering to this feature: http://snowadays.jp/2014/08/2983?lang=en https://github.com/arsduo/koala/issues/394

Tried getting this using oauth.io and I don't get any such value in the result. The result is always empty. (My Facebook connection does work, getting the user id, etc.)

Here is my code:

    result.get('/me/friends')
    .done(function (response) {

        console.log(response);
        console.log(response.summary.total_count);

    })
    .fail(function (err) {
        console.log('error: ', err);
    });

Upvotes: 1

Views: 777

Answers (2)

C3roe
C3roe

Reputation: 96454

You need to request user_friends permission from the user, otherwise you will not get any info about their friends, not even the total count.

Upvotes: 4

Tobi
Tobi

Reputation: 31489

You don't actually request the summary, so nothing is returned.

Try

/me?fields=friends.summary(true)

which should give you the desired result.

Upvotes: 0

Related Questions