开发者

Get friend's gender in a Facebook application

While developing a Facebook application I got the friendlist of a user by

$friends = $facebook->api('/me/friends');

But I only got to know the name and Facebook Ids of the friends : http://developers.facebook.com/docs/reference/api/FriendList

Is there any way to get the gender of 开发者_JAVA百科a friend?

One way to do so is to get the user's gender (since it is publicly available) given the user's facebook Id (which I have got using the friend list)

Is it really possible to do the above thing.

If not is there any other way?

for reference : http://developers.facebook.com/docs/reference/api/user


A quick way with Graph API

$facebook->api('me/friends?fields=id,name,gender,installed&access_token=[ACCESS_TOKEN]");


http://developers.facebook.com/docs/reference/api/FriendList = a persons fiend lists (plural) - eg: Limited Profile

What you want to do is get the ID from graph.facebook.com/me/firends and then do a graph.facebook.com/ID for the gender. But of course that ends up being a lot of requests if you need it for all of their friends.

For those cases you can use FQL query: http://developers.facebook.com/docs/reference/fql/

You can adopt following query from their documentation:

SELECT uid, name, pic_square FROM user WHERE uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())

Here name and gender of the current users friends:

SELECT uid, name, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜