首页 > 解决方案 > Facebook Graph API,无法使用应用令牌获取页面令牌

问题描述

使用图形 api,我正在尝试使用应用令牌(而不是使用用户令牌)获取页面令牌。

根据此处的文档,应该可以使用应用令牌:

https://developers.facebook.com/docs/facebook-login/access-tokens/

首先,我调用上面文档中提到的如下api来获取app token

https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=[client-id]&client_secret=[secret]

如上述文档所述:“此调用将返回一个应用访问令牌,该令牌可用于代替用户访问令牌来进行 API 调用”

我成功获取了应用令牌,然后我用它来获取页面令牌:

https://graph.facebook.com/[page-id]?fields=access_token&access_token=[token]

但在这里我得到以下错误:

 {
     "error": {
         "message": "(#100) Object does not exist, cannot be loaded due to missing permission or reviewable feature, or does not support this operation. This endpoint requires the 'pages_read_engagement' permission or the 'Page Public Content Access' feature or the 'Page Public Metadata Access' feature. Refer to https://developers.facebook.com/docs/apps/review/login-permissions#manage-pages, https://developers.facebook.com/docs/apps/review/feature#reference-PAGES_ACCESS and https://developers.facebook.com/docs/apps/review/feature#page-public-metadata-access for details.",
         "type": "OAuthException",
         "code": 100,
         "fbtrace_id": "[omitted]"
     }     
 }

如果我改用用户令牌,则可以轻松获取页面令牌,但在使用应用令牌时则不行。我可以看到我在我的应用程序中拥有 pages_read_engagement 权限和“标准访问权限”。有什么问题?

标签: facebookrestfacebook-graph-api

解决方案


推荐阅读