發送消息。當我從https://developers.facebook.com/docs/messenger-platform/send-api-referenceFacebook發送API - 無法使用用戶ID
curl -X POST -H "Content-Type: application/json" -d '{
"recipient":{
"id":"USER_ID"
},
"message":{
"text":"hello, world!"
}
}' "https://graph.facebook.com/v2.6/me/messages?access_token=PAGE_ACCESS_TOKEN"
我得到這個錯誤執行以下要求:
Graph returned an error: (#100) Parameter recipient[id]: Invalid id: "the id of the recipient"
的文檔指出:
The id must be an ID that was retrieved through the Messenger entry points or through the Messenger webhooks (e.g., a person may discover your business in Messenger and start a conversation from there. These IDs are page-scoped IDs (PSID). This means that the IDs are unique for a given page. If you have an existing Facebook Login integration, user IDs are app-scoped and will not work with the Messenger platform.
我不明白從哪裏得到id。有人可以解釋如何獲得在API中使用的ID?
你爲用戶使用了什麼ID?你究竟如何得到它?你知道你只能在用戶開始使用你的機器人後才能得到它,對嗎? – luschn
首先設置您的機器人,並與您的Facebook用戶發送消息。 facebook提供了示例代碼,只需查看文檔即可。你只有在用戶與你的機器人交互時纔會得到一個id。用示例代碼做一些測試,你會看到。 – luschn
當用戶發送消息時,您將獲得Page範圍的用戶ID。你不能只是給隨機的人發送消息 – WizKid