从 Facebook Graph API /user 获取 "real" 个人资料 URL
Get "real" profile URL from Facebook Graph API /user
如 /user
的 API docs 中所述,link
字段包含用户的个人资料 URL。但是,此 URL 通常会重定向到另一个 URL(即显示在 Google 结果中的那个)。
有什么方法可以通过 Facebook API 确定给定个人资料的最终重定向位置("real" URL)?
例如,给定:
"link":"https://www.facebook.com/1091552020"
我想从 API
中检索 https://www.facebook.com/sbhutiani
您无法再获取用户的真实 ID 或用户名,因此无法获取 "real URL"。更多信息:https://developers.facebook.com/docs/apps/changelog
您可以通过以下 API 调用获取用户个人资料 link:/me?fields=link
查看 Facebook 文档中的 "App Scoped IDs"。
更新:似乎无法再link访问用户个人资料:https://developers.facebook.com/blog/post/2018/04/19/facebook-login-changes-address-abuse/
看起来 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"
}
如果用户已批准该权限,您将能够像以前一样获取 link:
/me?fields=link
{
"link": "https://www.facebook.com/app_scoped_user_id/SOME_TOKEN/",
"id": "USER_ID"
}
如 /user
的 API docs 中所述,link
字段包含用户的个人资料 URL。但是,此 URL 通常会重定向到另一个 URL(即显示在 Google 结果中的那个)。
有什么方法可以通过 Facebook API 确定给定个人资料的最终重定向位置("real" URL)?
例如,给定:
"link":"https://www.facebook.com/1091552020"
我想从 API
中检索https://www.facebook.com/sbhutiani
您无法再获取用户的真实 ID 或用户名,因此无法获取 "real URL"。更多信息:https://developers.facebook.com/docs/apps/changelog
您可以通过以下 API 调用获取用户个人资料 link:/me?fields=link
查看 Facebook 文档中的 "App Scoped IDs"。
更新:似乎无法再link访问用户个人资料:https://developers.facebook.com/blog/post/2018/04/19/facebook-login-changes-address-abuse/
看起来 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"
}
如果用户已批准该权限,您将能够像以前一样获取 link:
/me?fields=link
{
"link": "https://www.facebook.com/app_scoped_user_id/SOME_TOKEN/",
"id": "USER_ID"
}