Facebook Messenger API:必须使用活动访问令牌来查询当前用户的信息



我在这里遵循开发指南:https://developers.facebook.com/docs/messenger-platform/quickstart

我已经设置了我的服务器和网络挂钩。当我试图向facebook图形api发出POST请求时,我得到了以下响应:

{"response":{"statusCode":400,"content":"{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500,"fbtrace_id":"GHWSIH8OBGm"}}","headers":{"www-authenticate":"OAuth "Facebook Platform" "invalid_request" "An active access token must be used to query information about the current user."","access-control-allow-origin":"*","pragma":"no-cache","cache-control":"no-store","facebook-api-version":"v2.6","expires":"Sat, 01 Jan 2000 00:00:00 GMT","content-type":"text/javascript; charset=UTF-8","x-fb-trace-id":"GHWSIH8OBGm","x-fb-rev":"2296043","vary":"Accept-Encoding","x-fb-debug":"4KebPKo5T+Al/88Z7DWtZ8ROawIB3cZFLp65OVi/soTB6hOHstvXox5czalYj45FdI+2r+MQwNh9PHur5uGSbQ==","date":"Wed, 20 Apr 2016 23:45:26 GMT","transfer-encoding":"chunked","connection":"keep-alive"},"data":{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500,"fbtrace_id":"GHWSIH8OBGm"}}}}

我正在使用应用程序页面提供的页面访问令牌。我使用fb令牌验证器来验证令牌是否已过期。

我很感激你的帮助。

错误消息显示您正试图查询与您的char bot通信的当前用户的信息。为用户信息提供服务的API端点是:

https://graph.facebook.com/v2.6/USER_ID_HERE?fields=first_name,last_name,profile_pic&access_token=PAGE_ACCESS_TOKEN_HERE

根据文档,您需要向这个端点发出GET请求(而不是POST)。

您可以使用用户配置文件API中的人员姓名或配置文件图片对对话进行个性化设置。为了获得这些信息,请向https://graph.facebook.com/v2.6/?fields=first_name,last_name,profile_pic&access_token=。阅读发送API参考中的更多详细信息。https://developers.facebook.com/docs/messenger-platform/implementation#user_profile_api

尝试将"Authorization"标头设置为值"Bearer PAGE_ACCESS_TOKEN",而不是"ACCESS_TOKEN:PAGE_ACCESS_TOKEN"

最新更新