Facebook Graph API - 如何从公开个人资料中获取性别 [英] Facebook Graph API - How to get Gender from Public Profile
问题描述
我需要通过Facebook Graph API从他的公开个人资料中获取Facebook用户的性别。
I need to retrieve the gender from a Facebook user from his public profile via Facebook Graph API.
不幸的是,这并不总是奏效。参见这些例子:
Unfortunately it is not always working. See these examples:
work:
https://graph.facebook .com / 1423993568
{
"id": "1423993568",
"gender": "male",
...
}
:
https://graph.facebook.com/10152133878666403
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
但是当我直接通过网络打开用户ID时,它可以工作,甚至可以看到性别。 (转到关于/联系和基本信息)我使用我的个人帐户登录,而不是该用户的朋友!
http://www.facebook.com/10152133878666403
But when I open the user id directly via web, it works, and I can even see the gender. (Go to "About/Contact and Basic Info") I am logged in with my personal account and not a friend of this user! http://www.facebook.com/10152133878666403
有什么问题?请问是Facebook的安全功能吗?
What is the problem? Is it a problem with the request or a security feature from Facebook?
更新:
我可以做一个这样的解决方法,但是只有当我使用浏览器登录时:
I can do a workaround like this, but only if I am logged in with my browser:
使用app_scoped_user_id并从重定向网址获取Facebook用户名,打开此请求时:
Take the app_scoped_user_id and get the Facebook username from the redirect URL, when opening this request:
http://www.facebook.com/app_scoped_user_id/10152133878666403
--> https://www.facebook.com/shiffoni
--> https://graph.facebook.com/shiffoni
返回:
{
"id": "669926402",
"first_name": "Shiffoni",
"gender": "female",
"last_name": "Leonhardt",
"locale": "de_DE",
"name": "Shiffoni Leonhardt",
"username": "shiffoni"
}
任何其他想法来获取性别,真实的userId或昵称? / p>
Any other ideas to get the gender, real userId, or nickname?
推荐答案
正如Facebook员工的评论中已经回答的,根本不可能,因为不支持性别或真实的Facebook用户ID。
As already answered in the comments by a Facebook employee, it is simply not possible, because it is not supported to get the 'gender' or the real Facebook user id.
可能的解决方法:
- 使用性别api(例如 genderize.io )根据第一个
名称检索性别。 - 从用户关于页面中删除Facebook上的性别信息(需要通过网络登录
)。
- use gender api (e.g. genderize.io) to retrieve gender based on first name.
- scrape the gender information from the Facebook (need to be logged in via web) from the user about page.
这篇关于Facebook Graph API - 如何从公开个人资料中获取性别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!