2016-04-20 54 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」

相關問題