Question

I am looking at the Graph API .. and how to get a persons friends, apparently its only returning the name and the ID of the friend, I don't know how to go about this, I need something like email to show them that these friends are already signed up for my site....

Sorta like what foursquare does

Was it helpful?

Solution

It depends on how you're keeping track of the friends in your application, if you just store their facebook id along with other info in your application then getting the friend list without any more parameters is enough as it returns id and name by default:

https://graph.facebook.com/me/friends?access_token=AUTH_TOKEN

returns:

{
   "data": [
      {
         "name": "Friend1",
         "id": "123456"
      }
   ]
}

If you aren't keeping track of any facebook info in your application and you want to compare based in some other field you would add the fields parameter and specify the field you want to search on:

https://graph.facebook.com/me/friends?access_token=AUTH_TOKEN&fields=name,picture

returns:

{
       "data": [
          {
             "name": "Friend1",
             "id": "123456",
             "picture": "http://profile.ak.fbcdn.net/hprofile-ak/blalala"                 
          }
    ]
}
  • id is always returned even if you don't specify it in the fields params.
  • email requires extended permissions to be granted once the user adds your application, and is not an option from the friend's list...

The full list of selectors/fields is here: http://developers.facebook.com/docs/reference/api/user

OTHER TIPS

http://developers.facebook.com/docs/authentication/permissions - friends email is not an available option. Presumably if the user has signed up to you via facebook, you could store their facebook ID and then query against that?

Because the user is logged in who's friends list you are going to fetch and off course you have authentication token against logged-in user, use this graph api url to get list in json format.

https://graph.facebook.com/me/friends?access_token=AUTH_TOKEN

And off course you have extended permissions for that user too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top