I'm doing a facebook messenger bot. After you start it, it makes a call to WebHook. Unfortunately after the first start will not stop throwing the same call with the same parameters. The settings are:
The source code is this: https://github.com/Ellusu/nuraghebot-facebookmessenger/blob/master/index.php
Where am I wrong? Why does only one call?
A webhook enables Stripe to push real-time notifications to your app. Stripe uses HTTPS to send these notifications to your app as a JSON payload. You can then use these notifications to execute actions in your backend systems. To learn more, see Stripe webhook events overview.
Response FormatYour Webhook URL should return a response with HTTP status code 200. Any other HTTP response code will be treated as a failure. It is not necessary for your Webhook response to return any content.
Webhooks are simple HTTP callbacks used to provide event notifications. Azure Logic Apps and Power Automate both allow you to use webhooks as triggers.
A webhook (sometimes called a reverse API) is an API endpoint that serves a different purpose: instead of just looking up information like a typical GET API endpoint, we can POST to the webhook with some JSON data, and then it'll do something internally. That means webhooks can serve as a sort of event system.
By your code I decided that you can't setup your webhook, so from documentation
At your webhook URL, add code for verification. Your code should expect the Verify Token you previously defined, and respond with the challenge sent back in the verification request. Click the "Verify and Save" button in the New Page Subscription to call your webhook with a GET request.
So, for PHP to make a success with webhook setup you must return hub_challenge parameter.
Define $verify_token with your token and add something like:
if (!empty($_REQUEST['hub_mode']) && $_REQUEST['hub_mode'] == 'subscribe' && $_REQUEST['hub_verify_token'] == $verify_token) {
// Webhook setup request
echo $_REQUEST['hub_challenge']; exit;
}
After success setup, you can delete this code from your script.
Or, if your webhook already hooked:
You should skip any read and delivery messages, like this:
if (!empty($input['entry'][0]['messaging'])) {
foreach ($input['entry'][0]['messaging'] as $message) {
// Skipping delivery messages
if (!empty($message['delivery'])) {
continue;
}
// Skipping read messages
if (!empty($message['read'])) {
continue;
}
}
}
Or, you can deselect message_reads & message_deliveries checkboxes in Page Subscription section of your Facebook Page Settings/Webhooks.
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