从Facebook Graph API /user获取“真实”的个人资料网址

22
API 文档中所述,/user 接口中的link字段包含用户的个人主页链接。但是,该链接通常会重定向到另一个链接(即在 Google 结果中显示的链接)。

是否有一种方式可以通过 Facebook API 确定给定个人主页的最终重定向位置(即“真实”链接)?

例如,给定以下内容:

"link":"https://www.facebook.com/1091552020"

, 我想从 API 检索出 https://www.facebook.com/sbhutiani

6
不可能的,这是预设设计。 - WizKid
2个回答

25

3
使用这个API调用:/me?fields=link,你将得到一个指向用户资料的链接。 - andyrandy
2
你只需要添加你想要的所有字段,用逗号分隔,就像你写的那样。你可以在API资源管理器中测试它: https://developers.facebook.com/tools/explorer/?method=GET&path=me%3Ffields%3Dlink&version=v2.10 如何使用它取决于SDK(如果您甚至使用任何SDK)。 - andyrandy
4
根据此帖子:https://developers.facebook.com/blog/post/2018/04/19/facebook-login-changes-address-abuse/,使用链接参数获取个人资料网址不再起作用,因为由于滥用,ASID目前无法解析。 - Atan
1
谢谢,我会把它加入到答案中! - andyrandy
根据Facebook文档https://developers.facebook.com/docs/graph-api/reference/v2.2/user,`link`字段未标记为“自2018年4月4日起不返回数据”。您认为它为什么被隐藏了? - alexanoid
显示剩余3条评论

7
似乎Facebook已经创建了一个单独的权限(用户需要批准)称为user_link,以便您能够获取该信息。您可以在此处查看更多详细信息:https://developers.facebook.com/docs/facebook-login/permissions/#reference-user_link 当您使用/me?metadata=1查询有关端点可用字段的元数据时,link描述如下:
{
  "name": "link",
  "description": "A link to the person's Timeline. The link will only resolve if the person clicking the link is logged into Facebook and is a friend of the person whose profile is being viewed.",
  "type": "string"
}

如果用户已经批准了该权限,您将能够像以前一样获取链接:
/me?fields=link

{
  "link": "https://www.facebook.com/app_scoped_user_id/SOME_TOKEN/",
  "id": "USER_ID"
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接