-1

Simply executing this query aiming to list all my friend's friends:

GET https://graph.facebook.com/hisFacebookUserId/friends?return_ssl_resources=1&access_token=hisAccessToken

I obtain an empty data entry. => as if it had 0 friends. (but he has 800).

However, it works for many other users.

What might be the reason?

Mik378
  • 21,881
  • 15
  • 82
  • 180

1 Answers1

1

Since v2.0 of the Facebook API, you can only get the friends who authorized your App too. It´s a (privacy) feature, not a bug.

https://developers.facebook.com/docs/apps/changelog

Also, it´s not necessary to use an ID for the call, because you can only get the friends of the authorized User anyway:

/me/friends

Btw, don´t forget to authorize Users with the user_friends permission.

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • Even if i don't specify the 2.0 in the URL? It can't use the 1.0 any more? – Mik378 Nov 19 '14 at 09:34
  • you can´t use 1.0 in an App created after April 2014 - or in an App that was inactive before that. – andyrandy Nov 19 '14 at 09:34
  • Ok, however I'm the owner of the app, (so authorized) and he's my friend. Why can't I see his friends whereas I can see any other user's friends. – Mik378 Nov 19 '14 at 09:35
  • Yes sorry, I misspoked. For example: A is logged on the app through his Facebook. It retrieves his friends. B should be among the result but B isn't present.. – Mik378 Nov 19 '14 at 09:38
  • please read my answer, that´s explained in there. you can ONLY get the friends of the authorized user and you can ONLY get those who authorized your app too. that´s how it is. – andyrandy Nov 19 '14 at 09:38
  • meaning: user B will only show up in the friendlist of user A if he authorized the app too – andyrandy Nov 19 '14 at 09:39
  • Exactly, that's why it's strange since both me and him, have authorized the application – Mik378 Nov 19 '14 at 09:39
  • in that case, you probably forgot to ask for the user_friends permission – andyrandy Nov 19 '14 at 09:39
  • Is it possible that this specific user (1 among 800) has restricted his access on his Facebook settings? – Mik378 Nov 19 '14 at 09:40
  • no, if he disabled the platform, he would not be able to use the app at all – andyrandy Nov 19 '14 at 09:41
  • I will check his permissions. It would make sense if ALL users were in the same case, but very weird, just him. – Mik378 Nov 19 '14 at 09:42
  • why? all those other users did not authorize your app, so of course they don´t show up in the list. – andyrandy Nov 19 '14 at 09:43
  • The context is: I've got an app where any users could authenticate through Facebook. For each user connected, I grab their friends that authorized the app. There are 800 users. For those 800 users, all respective friends list is well received. However for this 801th user...nothing. – Mik378 Nov 19 '14 at 09:45
  • ok, then it may indeed be a v1.0 app, and maybe it IS about a user setting. afaik you can hide friends on facebook.com, so even your friends don´t see...your friends...if you know what i mean. – andyrandy Nov 19 '14 at 09:47
  • Yes, I just debug his accessToken, it well has the `user_friends` scope... I investigate :) – Mik378 Nov 19 '14 at 09:48
  • Oh, I observe that it doesn't has the permission: `read_friendslist`, comparing to other users permissions. – Mik378 Nov 19 '14 at 09:50
  • Actually, no, there are other users that doesn't have it. So not essential. – Mik378 Nov 19 '14 at 09:54
  • 1
    that permission is irrelevant, it´s for friendlists, not friends – andyrandy Nov 19 '14 at 09:54