访问Facebook的公开个人资料和性别

时间:2015-10-29 13:59:49

标签: facebook facebook-graph-api

我正在开发一个网络应用,我需要访问Facebook用户的公开个人资料图片和性别。以前我可以使用Facebook Graph API轻松完成。任何人都可以建议我现在如何访问它?感谢。

1 个答案:

答案 0 :(得分:-1)

Use the api to return a user object which has property for gender.

JavaScript API example:

/* make the API call */
FB.api(
    "/{user-id}",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);

Graph API Reference- User

Note: The gender will be blank if the user is using a custom gender.


You can also use this to get the gender if you know the facebook id and the user's profile is public.

http://graph.facebook.com/<facebook_id>?fields=gender

fields=gender gives you the gender for the given facebook id.