扩展Facebook页面访问令牌 [英] Extending Facebook Page Access Token
问题描述
我需要扩展我的Facebook访问令牌,我叫这个:
i need to extend my facebook access token, I'm calling this:
https://graph.facebook.com/oauth/access_token?
client_id={MY PAGE ID}&
client_secret={THE SECRET KEY OF MY APP}&
grant_type=fb_exchange_token&
fb_exchange_token={AN ACCESS TOKEN FOR MY PAGE}
我收到此错误:
"error": {
"message": "Error validating application. Cannot get application info due to a system error.",
"type": "OAuthException",
"code": 101
}
我看到这个access_token有很多问题,但是没有相关页面的答案,idk为什么Facebook使用api,为什么...但是...的方式...
I've seen a lot of problem with that access_token, but none answer relative to pages, idk why facebook use api that why... but is the way...
谢谢,
推荐答案
要获得一个长久的访问令牌,您需要按照以下步骤:
To get a long-lived access token you need to follow those steps:
- 创建应用程序
- 创建一个页面(您的帐户需要管理员)
-
将应用程序关联到页面(与您要向页面添加页面标签页时的方式相同)
- Create an Application
- Create a Page (your account need to be "administrator" of the page)
Associate the application to the Page (the same way you do it when you want to add a Page Tab to a Page)
http://facebook.com/add.php?api_key=*YOUR_APP_ID*&pages=1&page=*YOUR_PAGE_ID*
获取一个短命的访问令牌,具有权限
Get a short-lived access token with the permission "manage_pages" associated to your Application.
https://graph.facebook.com/oauth/authorize?client_id=__APP_ID__&scope=manage_pages&redirect_uri=http://www.facebook.com/connect/login_success.html
then
https://graph.facebook.com/oauth/access_token?client_id=__APP_ID__&redirect_uri=http://www.facebook.com/connect/login_success.html&client_secret=__APP_SECRET__&code=__CODE_FROM_PREVIOUS_REQUEST__
使用Graph API Explorer查询请求 / me / accounts 您可以看到您所管理的每个页面的访问令牌。问题是这些访问令牌是短命的。
Using the Graph API Explorer with the request /me/accounts you can see the access tokens for each Pages that you are administrator. The problem is that those access token are short-lived.
将短命令访问令牌转换为长命令(扩展访问令牌):
Convert your short-lived access token to a long-lived (extending access token):
https://graph.facebook.com/oauth/access_token?client_id=_APP_ID_&client_secret=_APP_SECRET_&grant_type=fb_exchange_token&fb_exchange_token=_ACCESS_TOKEN_ON_STEP_4_
现在,您可以使用访问令牌调试器。
这篇关于扩展Facebook页面访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!