Facebook Messenger API: Trouble setting up a webhook Facebook Messenger API: Trouble setting up a webhook php php

Facebook Messenger API: Trouble setting up a webhook


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.


Not sure if this help, but the query parameters that FB send are with underscore not dot e.g. :

  • hub_verify_token
  • hub_mode
  • hub_challenge

P.S.

Sorry, this is valid for PHP