【问题标题】:Facebook Messenger API : An active access token must be used to query information about the current userFacebook Messenger API:必须使用活动访问令牌来查询有关当前用户的信息
【发布时间】:2016-08-13 22:11:06
【问题描述】:

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

我已经设置了我的服务器和 webhook。当我尝试向 facebook graph 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 令牌验证器来验证令牌没有过期。

感谢您对此提供的任何帮助。

【问题讨论】:

  • 您提出的实际发布请求是什么?

标签: facebook facebook-graph-api facebook-messenger


【解决方案1】:

错误消息显示您正在尝试查询有关当前用户与您的 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= 发出 GET 请求。在发送 API 参考中阅读更多详细信息。 https://developers.facebook.com/docs/messenger-platform/implementation#user_profile_api

【讨论】:

  • 我也遇到了同样的问题,我尝试构建的演示肯定使用 POST 通过信使向用户发送数据。问题似乎在于 Facebook 甚至不允许您在他们审查应用程序之前玩弄或测试您的聊天机器人。
  • USER_ID_HERE 是什么?是/me吗?
  • 这是您在 webhook 上收到的消息的“发件人 ID”。
  • 同样的问题,USER_ID_HERE是我
【解决方案2】:

尝试将“Authorization”标头设置为“Bearer PAGE_ACCESS_TOKEN”而不是“access_token: PAGE_ACCESS_TOKEN”

【讨论】:

    猜你喜欢
    • 2012-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-19
    • 2011-08-27
    相关资源
    最近更新 更多