Facebook Messenger API: Trouble setting up a webhook

Shane picture Shane · Apr 13, 2016 · Viewed 22k times · Source

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='

Resources

https://developers.facebook.com/docs/messenger-platform/quickstart

https://developers.facebook.com/docs/messenger-platform/webhook-reference#common_format

Any help is greatly appreciated.

Answer

Shane picture Shane · Apr 13, 2016

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/