开发者

How to use the Graph API to show the user his facebook friends that have already signed up for my site

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


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜