Anand Gajjar
Anand Gajjar

Reputation: 81

how to handle $updates array in Facebook real time update callback.php page

Here is the code of Facebook callback.php page.
Now how can I handle post method response ($updates variable)?

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); 

  //what to do here.

  error_log('updates = ' . print_r($updates, true));              
}

Upvotes: 3

Views: 841

Answers (1)

AlexanderN
AlexanderN

Reputation: 2670

Since many people seem to be struggling with this, I therefor decided to make a detailed tutorial on how to use the Facebook Real-Time Updates API:

http://www.codedestination.com/1/post/2013/05/-facebook-real-time-updates-api-tutorial-part-i.html

What you are looking for is explained in part two of the tutorial-series.

It explains both how to decode the JSON object notifications that you receive from FaceBook and also how to store these updates into your own database.

I hope this helps! Best of luck!

Upvotes: 1

Related Questions