如何在Facebook实时更新callback.php页面中处理$ updates数组

时间:2012-04-05 11:59:49

标签: php facebook real-time

以下是Facebook callback.php页面的代码 现在我该如何处理post方法响应($ 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));              
}

1 个答案:

答案 0 :(得分:1)

由于许多人似乎都在努力解决这个问题,因此我决定制作一份关于如何使用Facebook Real-Time Updates API的详细教程:

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

教程系列的第二部分解释了您要寻找的内容。

它解释了如何解码从FaceBook收到的JSON对象通知,以及如何将这些更新存储到您自己的数据库中。

我希望这有帮助!祝你好运!