1

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);
    });
eyal_katz
  • 1,111
  • 10
  • 17
  • Hi eyal. I am trying to integrate facebook with oauth.io but its not working.. take a look at http://stackoverflow.com/questions/31639811/getting-the-parameter-app-id-is-required-with-oauth-io and suggest me if I am missing something – G_S Jul 27 '15 at 02:12

2 Answers2

4

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.

CBroe
  • 91,630
  • 14
  • 92
  • 150
  • This is from the Facebook App admin page: "user_friends Provides access to a person's list of friends that also use your app. This permission is approved by default." Is there anything I can do from the ioath.io to improve this? – eyal_katz Apr 30 '15 at 14:08
  • “Approved by default” only means that your app is _allowed_ to ask users for it without having to submit for review; you still have to _ask_ users to grant your app that permission however (via `scope` in the standard login dialog.) – CBroe Apr 30 '15 at 14:32
  • It appears that oauth.io requires you to add the "scope" in their admin panel. I am trying to do so, but it doesn't save with no message.. It's the "Keys and Permission Scope" page when you manage your "Integrated API". You can select Facebook API version and then scope. But it doesn't save when I edit.. – eyal_katz Apr 30 '15 at 17:02
0

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

Try

/me?fields=friends.summary(true)

which should give you the desired result.

Tobi
  • 31,405
  • 8
  • 58
  • 90
  • The problem is that this may not be possible using oauth.io, can I do this: result.get('/me/friends?fields=friends.summary(true)') doesn't seem to work.. – eyal_katz Apr 30 '15 at 13:45