PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of uche   Basic PHP Facebook Messenger Bot   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Basic PHP Facebook Messenger Bot
Exchange messages with Facebook Messenger users
Author: By
Last change:
Date: 2 years ago
Size: 854 bytes


Class file image Download
/*Created by MmuoDev.
require_once 'classes/botClass.php';

if (isset(
$_GET['hub_verify_token'])) {
    if (
$_GET['hub_verify_token'] === VERIFY_TOKEN) { //Token entered during setup. It is defined as a constant in constants.php
echo $_GET['hub_challenge'];
    } else {
'Invalid Verify Token';
$accessToken = ACCESS_TOKEN; //Access token generated by Facebook. It is defined as a constant in constants.php.
$bot = new botClass(); //Initialize an object of the bot class
$input = json_decode(file_get_contents('php://input'), true); //JSON decode messages received
$message = $bot->readMessage($input); //Call the method that reads messages
$bot->sendMessage($message); //Call the method that sends messages