0

My goal is to get a list of user facebook friends using Facebook Graph API. At least those, who have used social authentication on my website

I have read, that after v2.0 I can get only a list of friends, if the following conditions are met:

A user access token with user_friends permission is required to view the current person's friends. This will only return any friends who have used (via Facebook Login) the app making the request. If a friend of the person declines the user_friends permission, that friend will not show up in the friend list for this person.

When I get a token and check

/v2.5/me/permissions

Result:

{
  "data": [
    {
      "permission": "user_friends",
      "status": "granted"
    },
    {
      "permission": "public_profile",
      "status": "granted"
    }
  ]
}

I am testing 2 user accounts, who are friends. I have used both for login in my web application using Facebook Login. But when I do

v2.5/me/friends

Result:

{
  "data": [
  ],
  "summary": {
    "total_count": 1
  }
}

What is the reason of empty friends set?

1 Answers1

0

Make sure all those friends authorized your App with user_friends too. If they only authorized without user_friends, they will not show up. The response looks like it worked correctly.

Sidenote: It is not allowed to have 2 user accounts on Facebook, you can only have one account - with your real name.

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • How can I check if friends authorized my App with user_friends? Where can it be checked? – Vladimir Shevchenko Nov 30 '15 at 09:50
  • ask your friends if they authorized it, or check their access token. in any case, if they don´t show up in the list from /me/friends, they did not authorize it. – andyrandy Nov 30 '15 at 09:53
  • You are right. There is no user_friends permission. But it's impossible to check it, because there are only 2 options (public_profile and email). If I press edit permissions I see only these two. But it supposed to be enabled by default and I saw green light on it in settings. – Vladimir Shevchenko Nov 30 '15 at 10:07
  • where exactly do you "edit permissions"? you have to implement a proper login process with the user_friends scope. – andyrandy Nov 30 '15 at 10:39
  • When I use an account of a friend I press facebook button in my web-app, then print email/password in popup. then I get a page with `continue as ***` and `will receive the following info: your public profile and email address.`. I click the link `edit the info you provide` and I see only 2 permissions available: `public profile` and `email address`. There is no permission `user_friends` to choose – Vladimir Shevchenko Nov 30 '15 at 11:17
  • then there is something wrong with your login process – andyrandy Nov 30 '15 at 11:31