I understand that when using the Facebook Messenger API, you MUST respond with a 200 OK
header after receiving any webhook event or else the API will keep resending the webhook event every 20 second until a 200 OK
is received as stated here https://developers.facebook.com/docs/messenger-platform/webhook/#response
I responded with the 200 OK
header with the code below
<?php
header('HTTP/1.0 200 OK');
//.. some define here
//check token at setup
if(isset($_REQUEST['hub_verify_token']) && $_REQUEST['hub_verify_token'] === HUB_VERIFY_TOKEN){
echo $_REQUEST['hub_challenge'];
exit;
}
else{
$input = file_get_contents('php://input');
//... further process
}
With this, the API is not receiving the 200 OK
as it keeps resending the webhook multiple times (like 100 times) and new webhooks are not delivered but when I send a message to the sender_id, it delivers.
Below is just the last 3 of about 100 I kept receiving. What am I doing wrong?
{"object":"page","entry":[{"id":"2229337433988598","time":1553082378936,"messaging":[{"sender":{"id":"2328261693885002"},"recipient":{"id":"2229337433988598"},"timestamp":1553080021611,"message":{"mid":"We9JyA5teKm4AjvtFU8Kqbf5aDr8mkTfciEIlko_ULGdUfl-gvMp8dafqKxc0QBVyPDtOsqQZuK_xImKfqm69Q","seq":40930,"text":"calm"}}]}]}
{"object":"page","entry":[{"id":"2229337433988598","time":1553082476255,"messaging":[{"sender":{"id":"2328261693885002"},"recipient":{"id":"2229337433988598"},"timestamp":1553080021611,"message":{"mid":"We9JyA5teKm4AjvtFU8Kqbf5aDr8mkTfciEIlko_ULGdUfl-gvMp8dafqKxc0QBVyPDtOsqQZuK_xImKfqm69Q","seq":40930,"text":"calm"}}]}]}
{"object":"page","entry":[{"id":"2229337433988598","time":1553082569721,"messaging":[{"sender":{"id":"2328261693885002"},"recipient":{"id":"2229337433988598"},"timestamp":1553080021611,"message":{"mid":"We9JyA5teKm4AjvtFU8Kqbf5aDr8mkTfciEIlko_ULGdUfl-gvMp8dafqKxc0QBVyPDtOsqQZuK_xImKfqm69Q","seq":40930,"text":"calm"}}]}]}
{"object":"page","entry":[{"id":"2229337433988598","time":1553082667807,"messaging":[{"sender":{"id":"2328261693885002"},"recipient":{"id":"2229337433988598"},"timestamp":1553080021611,"message":{"mid":"We9JyA5teKm4AjvtFU8Kqbf5aDr8mkTfciEIlko_ULGdUfl-gvMp8dafqKxc0QBVyPDtOsqQZuK_xImKfqm69Q","seq":40930,"text":"calm"}}]}]}
{"object":"page","entry":[{"id":"2229337433988598","time":1553082753466,"messaging":[{"sender":{"id":"2328261693885002"},"recipient":{"id":"2229337433988598"},"timestamp":1553080021611,"message":{"mid":"We9JyA5teKm4AjvtFU8Kqbf5aDr8mkTfciEIlko_ULGdUfl-gvMp8dafqKxc0QBVyPDtOsqQZuK_xImKfqm69Q","seq":40930,"text":"calm"}}]}]}