Currently I am developing a simple facebook messenger chatbot. I am using localhost url to tunnel via ngrok. I have also created a facebook app and a page on which bot should run. I also created a webhook for it. Everything was done successfully without any issue. But the problem is I can not get the reply from bot to work. I am receiving user's message but I can not get the bot to reply. So the user is not getting anything as a reply. Although in ngrok web interface I can see that the string which I want the bot to reply is there, but somehow it doesn't get send to the user as a reply. Here is the code for it. Can anyone point out the mistake? here is the ngrok inspect
Here is the code of my php file that is being called.
<?php
if (isset($_GET['hub_verify_token'])) {
if ($_GET['hub_verify_token'] === 'verify_token') {
echo $_GET['hub_challenge'];
return;
} else {
echo 'Invalid Verify Token';
return;
}}$input = json_decode(file_get_contents('php://input'), true);if (isset($input['entry'][0]['messaging'][0]['sender']['id'])) {
$sender = $input['entry'][0]['messaging'][0]['sender']['id'];
$message = $input['entry'][0]['messaging'][0]['message']['text'];
$jsonData = [
'recipient' => [ 'id' => $sender],
'message' => [ 'text' => $message]
];
$url = "https://graph.facebook.com/v2.8/me/messages?access_token=EAAQlAQ9iGz8BABZATCZAN0hd5eyJ2mCFZBR9rDuZARkEmeqh8obC0yZBpiGxFuNbAyi6HHFI2lZCCiILeFNFDuiy2Sb9OHpLfDSIBhCsv7FgglOrzZAqy9yDFlUTZCEHfRfXBYjZCQOj42Vhl4muvyGIqqqsGDP1a0FYcGo9on3QlzgKp5JL8XbZBx";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($jsonData));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_exec($ch);
curl_close($ch);}?>