Skip to content

Instantly share code, notes, and snippets.

@joseadrian
Forked from AlexanderNorway/facebook_subscribe.php
Created November 7, 2013 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joseadrian/7362728 to your computer and use it in GitHub Desktop.
Save joseadrian/7362728 to your computer and use it in GitHub Desktop.
<?php
define('VERIFY_TOKEN', 'yourappssecret');
$method = $_SERVER['REQUEST_METHOD'];
if ($method == 'GET' && $_GET['hub_mode'] == 'subscribe' && $_GET['hub_verify_token'] == VERIFY_TOKEN) {
echo $_GET['hub_challenge'];
} else if ($method == 'POST') {
$updates = json_decode(file_get_contents("php://input"), true);
// Here you can do whatever you want with the JSON object that you receive from FaceBook.
// Before you decide what to do with the notification object you might aswell just check if
// you are actually getting one. You can do this by choosing to output the object to a textfile.
// It can be done by simply adding the following line:
// file_put_contents('/filepath/updates.txt',$updates, FILE_APPEND);
error_log('updates = ' . print_r($obj, true));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment