I am trying to set up a web hook for the new Facebook Messenger bot platform on my PHP webserver and am receiving this error:
The URL couldn't be validated. Response does not match challenge, expected value = '364011207', received='
https://developers.facebook.com/docs/messenger-platform/quickstart
https://developers.facebook.com/docs/messenger-platform/webhook-reference#common_format
Any help is greatly appreciated.
Configure the webhook for your app In the 'Webhooks' section of the Messenger settings console, click the 'Setup Webhooks' button. In the 'Callback URL' field, enter the public URL for your Facebook webhook.
With webhooks, it's generally a three-step process: Get the webhook URL from the application you want to send data to. Use that URL in the webhook section of the application you want to receive data from. Choose the type of events you want the application to notify you about.
Webhooks allows you to receive real-time HTTP notifications of changes to specific objects in the Facebook Social Graph.
I came across a fix. I scrapped my js attempt and created a new php file with the following code:
<?php
$challenge = $_REQUEST['hub_challenge'];
$verify_token = $_REQUEST['hub_verify_token'];
if ($verify_token === 'my_token_code') {
echo $challenge;
}
I got this code from the first 10 minutes of this video: https://www.facebook.com/marketingdevelopers/videos/883648801749520/
That code is node.js code and should be run on the server not in a <script>
tag in your HTML.
Here's a simple walk through of setting up the messenger bot with node.js: https://github.com/voronianski/simon-le-bottle
Essentially you need to make sure you have a host that supports node.js applications and run it as such. It will not work inside of HTML.
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