<?php
/* Template Name: Webhook Handler */
// Exit if accessed directly
if (!defined('ABSPATH')) {
exit;
}
// Handle GET request for verification
if ($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['hub_verify_token'])) {
$verify_token = '20vnq3t[]g29u4h4\bisnh.,/'; // Replace with your verify token
if ($_GET['hub_verify_token'] === $verify_token) {
echo $_GET['hub_challenge'];
exit;
} else {
echo 'Invalid verify token';
exit;
}
}
// Handle POST request for webhook events
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$input = file_get_contents('php://input');
$data = json_decode($input, true);
// Log the incoming data for debugging
error_log(print_r($data, true));
// TODO: Add your logic to handle the webhook data here
echo 'OK';
exit;
}
