-
-
Save humannus/de8e95f13865d4f7cde9062c2bbe9105 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$token = 'secret'; | |
// check token in every request | |
if (!isset($_GET['token']) || $_GET['token'] !== $token) { | |
header('HTTP/1.0 401 Unauthorized'); | |
exit(); | |
} | |
// verification request | |
if ($_SERVER['REQUEST_METHOD'] === 'GET') { | |
exit($_GET['challenge']); | |
} | |
// access the body of a POST request | |
$data = json_decode(file_get_contents('php://input')); | |
header('Content-Type: application/json'); | |
$response = array( | |
// return custom attributes object | |
'attributes' => array( | |
'name' => 'John', | |
'surname' => 'Example' | |
), | |
// return responses | |
'responses' => array( | |
array( | |
'type' => 'text', | |
'message' => 'Message from webhook' | |
) | |
) | |
); | |
echo json_encode($response); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment