开发者

Facebook Graph API: user gender

Th开发者_运维技巧e old Facebook API provided the user sex/gender as part of the default user data. Apparently the new Graph API does not provide that information, even though the documentation says that it does.

I've heard people say that you need to request special permissions to get it and other pieces of data, but I have not been successful in getting it to work.

Does anyone have an example, using the Facebook Graph API, of how to get the user's gender and/or location (city/state/country/whatever)?


You need user_location permission to get the location according to the API reference.

GET https://graph.facebook.com/USER_ID?fields=gender,location

The Graph API tool explorer is a really handy tool for checking the output.


Just FYI, location (City and state only, country is still missing) and gender have been added to the Graph API sometimes today.

I was testing an app tonight and noticed there was a couple more fields :)


I see this has an open bounty even though the question is really really old.

You can get the gender of any user using Open Graph even without any access_token.

GET https://graph.facebook.com/userid
json_decode the data
gender will be in the `gender` element of the returned array.

EDIT : user location, hometown, country etc are no more there in the /me. seems like Fb removed those, even if they are public.

Hope this helps


As far as I can tell some permissions like user_location simply aren't working at the moment. I can get email permissions and some others but for most of the user_... ones, nope. Yes they are wrong about gender as part of default data and there appears to be no permission for it either. So use the old api until the kinks in the new one get worked out.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜