facebook graph api..get friends of friends
Asked Answered
Z

3

13

I am using the FB graph api to get a list of my friends' friends using:

https://graph.facebook.com/<id>/friends?access_token=<token>

Now the weird thing is that this works for some of my friends and does not work for some others. Could somebody tell me why this is happening and a possible fix?

In cases where it does not work, I get the following message: "Can't lookup all friends of YYYYYY. Can only lookup for the logged in user (XXXXX), or friends of the logged in user with the appropriate permission"

And I repeat, I AM ABLE to get friend lists of some of my friends using the above URL. What permissions are being mentioned here?

Zebu answered 17/4, 2011 at 4:7 Comment(0)
S
12

Privacy permissions.

As a user, I control who can see my friends list. If I select "Friends only" then only my friends can see my list, not "friends of friends"

Log into facebook, on the upper right click on Account -> Privacy settings, then Click on "View Settings" under "Connecting on Facebook"

"See your friends list" is what controls this.

Edit: Sorry, had to think about that for a minute.

You can see your friend's friends via the standard Facebook web UI. Your app is not you. Even though you've granted the app access to your account, your friends have not. In that case, you're not going to get back your friend's friends unless they have it set to "Everyone". Your app is not a friend of a friend.

I believe that's the reason. The other reason could be that their API is renown for being buggy. You could always open a bug report on http://bugs.developers.facebook.net/ and if my supposition is correct, someone will let you know.

Statolatry answered 17/4, 2011 at 4:22 Comment(3)
Yes, I checked that immediately after making this post. Even though I can see friends of my friends on the facebook website, the API call does not fetch them. Only some of the calls succeed. It is not consistent.Zebu
Thanks for the response Brian. I am actually not retrieving that information using a facebook app. I am making plain old HTTP calls using my access token (see the URL I posted above). I think that is closer to "me" than a facebook app. That is what had me confused.Zebu
There's no difference. The "Graph API" is just a REST-ful interface. Doesn't matter if you're using an "app" or your browser and including the access token - it's all just HTTP requests. When you include the access token the request is done in the context of the app.Statolatry
F
8

I got friends of friends(limited). I had same problem. Though it is very late for answering question, it will help somebody. That's why answering this question.

We can get friends of friends those are app users. Try by this fql query.

$fb_id= user id whose friends of friends required.

$query="SELECT uid, name, work_history  FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 IN (SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = $fb_id ) and is_app_user=1) )";
        $user_info=$facebook->api(array('method'=>'fql.query',
                    'query'=>$query));
Fionafionna answered 25/2, 2012 at 12:18 Comment(0)
O
1

Indeed. It's all http requests. But if I click on the link to show John's friends, facebook lists them, and if I use the graph api and a token, it doesn't. Either way it's me asking, but the api is inconsistent.

Osmosis answered 15/7, 2011 at 23:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.