Luca Davanzo
Luca Davanzo

Reputation: 21520

Facebook Graph API explorer: get friends of friends

Is there a way to retrieve friends of a friend?
I'm using SDK 1.0.

For example, I get first my id to retrieve list of my friend

NSString *query = [NSString stringWithFormat:@"/%@/friends", userID ];
[QVFacebookQuery execute:query withHTTPMethod:@"GET" completion:^(BOOL success, id result, NSError *error) {
    /* print result if success */ 
}];

With this method I can retrieve list of my friend and relative user id.

If I use one of this id to query its friends, never works!

  .../user_id/friends

I get this error:

{
  "error": {
    "message": "Unsupported operation", 
    "type": "OAuthException", 
    "code": 100
  }
}

I've already read documentation and set up user_friends permission.

Upvotes: 0

Views: 354

Answers (2)

Jeff Ames
Jeff Ames

Reputation: 1554

You need to use the mutualfriends endpoint. An example request would be of the form {user-id-a}/mutualfriends/{user-id-b}. So your query would be...

NSString *query = [NSString stringWithFormat:@"%@/mutualfriends/%@", firstUserID, secondUserID];

Note this will work for Graph API v1.0 but has been deprecated in newer versions.

https://developers.facebook.com/docs/graph-api/reference/v1.0/user/mutualfriends

Upvotes: 2

andyrandy
andyrandy

Reputation: 73984

You can´t get friends of a friend, for privacy reasons. You can´t even get all friends of the authorized user anymore - only those who authorized the app too.

Read more about the changes in the changelog: https://developers.facebook.com/docs/apps/changelog

Upvotes: 2

Related Questions