When I execute the following request from https://developers.facebook.com/docs/messenger-platform/send-api-reference
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"
I get this error:
Graph returned an error: (#100) Parameter recipient[id]: Invalid id: "the id of the recipient"
The documentation states that:
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.
I don't understand where to get the id from. Can someone explain how to obtain the id to use in the API?
You get the userID from the webhook when a user messages you. This ID is not the ID of the user, instead every user gets assigned a unique ID when it enters your page. This ID is then used to communicate between your page and the user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With