2016-04-20 56 views
4

我正在关注的发展莅临指导信息:https://developers.facebook.com/docs/messenger-platform/quickstart透过Facebook Messenger API:活动访问令牌必须用于查询当前用户

我设置我的服务器和网络挂接。当我尝试做一个POST请求到Facebook的图形API,我得到如下回应:

{"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令牌验证器来验证令牌未过期。

我感谢任何帮助。

+0

什么是实际的POST请求你在做? – user3268305

回答

2

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

+1

我有同样的问题,我尝试构建的演示绝对使用POST通过信使发送数据给用户。问题似乎是,Facebook甚至不会让你在审查应用程序之前玩弄或测试你的chatbot。 – wortwart

+1

什么是“USER_ID_HERE”?那是'/我'? – astiefel

+0

这是您在webhook上收到消息的'发件人ID'。 –

2

尝试使用值“承载PAGE_ACCESS_TOKEN”设置“授权”头,而不是“的access_token:PAGE_ACCESS_TOKEN”

相关问题