Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting friends of friends in FB graph API

I would like to get friends of friends via an API call and when I try to do it, I get the following exception,

    {
   "error": {
      "type": "OAuthException",
      "message": "(#604) Can't lookup all friends of .... Can only lookup for the logged in user (...), or friends of the logged in user with the appropriate permission"
   }
}

The URL I am trying to access is,

https://graph.facebook.com/friend_id/friends?access_token=access_token

I am getting extended permissions which is as follows,

<fb:login-button perms="user_likes,friends_likes"></fb:login-button>

Could any one please let me know what's going wrong here? Or does it mean I can never get access to friends of friends?

like image 670
Abhishek Avatar asked Sep 29 '10 03:09

Abhishek


People also ask

What data can I get from Facebook Graph API?

The Facebook Graph API is all about getting data into and out of Facebook. With this API, you can query data and create powerful dashboards to understand your content and audience better. For example, you can extract information from your own Page that shows who wrote each post and how many people liked it.

Is Facebook Graph API deprecated?

Graph API Version Deprecations: November 2, 2021: Graph API v4. 0 will be deprecated and removed from the platform. February 3, 2022: Graph API v5. 0 will be deprecated and removed from the platform.

How do I use Facebook Graph API and extract data?

To use the Graph API Explorer tool, go to developers.facebook.com/tools/explorer. Generate the access token you need to extract data from the Facebook Graph API by selecting Get User Access Token from the App Token drop-down menu under the name of your app.

How do I share a Facebook post on a graph API?

Yes, you can share using the graph2 api. The way you do it is to use /feed edge and pass the post's url that you want to share as the link. Standard Fb permissions to the post you are sharing do apply. This was done today, in a local rails app, using FbGraph2 gem, with the above method.


2 Answers

Currently, there is no extended permission that allows you to view a user's friends of friends. The "*_likes" permissions just show you the Facebook pages that the users have Liked.

It might be possible for you to iteratively fetch and cache the friends of each of the user's friends, one by one, but without access tokens for each friend, you'll only be able to fetch public data.

like image 179
Raphomet Avatar answered Sep 23 '22 16:09

Raphomet


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. $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));

@Olie:

You are fetching your friends of your friend through application. So you would need permission from your friend whose friends you want. i.e. Your friend should be using that application and accepted those permission while allowing accessing information. Otherwise you wont be able to friends of your friend. I have tested this query. And it works successfully.

"message": "(#604) Can't lookup all friends of .... Can only lookup for the logged in user (...), or friends of the logged in user with the appropriate permission"

This message explains well. Read carefully.

Hope you understand solution criteria.

like image 25
Somnath Muluk Avatar answered Sep 22 '22 16:09

Somnath Muluk