I'm suddenyly getting errors in my facebook messenger service that sends messages from my website to a facebook chat. The error is
"type":"OAuthException","code":10,"error_subcode":2018278,"fbtrace_id":"AJSz9EQPjUFjShr0QK34yEr"}} {"error":{"message":"(#10) This message is sent outside of allowed window. Learn more about the new policy here:
I have seen this note on the facebook API pages On March 4th, 2020 we introduced Messenger webhook versioning with v6.0 having the first versioned change for the messages field.
Here is my code for sending a message
` $url = 'https://graph.facebook.com/v2.6/me/messages?access_token=';
/* initialize curl */
$ch = curl_init($url);
/* prepare response */
$jsonData = '{
"recipient":{
"id":"' . $sender . '"
},
"message":{
"text":"' . $message . '"
}
}';
/* curl setting to send a json post data */
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
if (!empty($message)) {
$result = curl_exec($ch); // user will get the message
}`
Can someone explain what FB has changed to make this not work and what the new alternative is or how I can correct my own code.
Thanks
https://developers.facebook.com/docs/messenger-platform/changelog/