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

Here is the Facebook page code callback.php

.
Now how can I handle the 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));              
}

      

+3


source to share


1 answer


Since a lot of people seem to be struggling with this, so I decided to make a detailed tutorial on how to use the Facebook Live 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 the second part of the tutorial series.



It explains how to decode the JSON object notifications you receive from FaceBook, as well as how to store these updates in your own database.

Hope this helps! Good luck!

+1


source







All Articles