English 中文(简体)
Facebook Graph API: user gender
原标题:

The 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)?

最佳回答

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 :)

问题回答

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.

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.





相关问题
Facebook Connect login dialog not working

I am using Facebook Connect for iPhone and following the official instructions. I use the following code to display the login dialog: FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:...

Facebook App Profile Tab is Empty ... No Content Displayed?

I can view my application via the http://apps.facebook.com/myapplication/ link and the content shows up correctly. I also added the application as a tab to a facebook page. However, when viewing the ...

Facebook Platform error: "Object cannot be liked"

I m working on a Facebook Application that generates wall posts. In testing these posts, I ve discovered that the Facebook Platform action of "liking" a post is failing. The specific error message ...

how to call showPermissionsDialog() in php (facebook api)?

I was reading over the documentation yet I could not figure out how to call Facebook.showPermissionsDialog() in php include_once ./facebook-platform/php/facebook.php ; $facebook = new Facebook(my ...

Facebook connect

If I plug in the facebook connect into my website, How can I prevent double signups? Lets say I have a user that s already signed up to my site but he clicked the connect with facebook, is there a ...

热门标签