Facebook实时页面更新php

Facebook real time page update php

这是我对Whosebug的第一个问题,所以如果有什么不对的地方请指教.. 那么问题是 Facebook 实时更新: 我已成功创建对页面的订阅及其管理员用户(已创建测试页面和测试应用程序),用户已同意 manage_page、read_stream、read_friendlist、read_insights、publish_actions 和大量用户数据(关于、电子邮件等) 当我使用 edge /subscriptions 查询 GET to Graph api 时,我得到的结果是:

{
  "data": [
    {
      "object": "user", 
      "callback_url": "LIVE_CALLBACK_URL", 
      "fields": [
        "feed"
      ], 
      "active": true
    }, 
    {
      "object": "page", 
      "callback_url": "LIVE_CALLBACK_URL", 
      "fields": [
        "built", 
        "description", 
        "email", 
        "feed", 
        "location", 
        "name", 
        "personal_info", 
        "written_by"
      ], 
      "active": true
    }
  ]
}

所以,这已经解决了,之后我搜索了为什么 Facebook 没有向我发送任何更新(我登录到 somefile.txt)所以我发现你需要查询图表 api 使用 /tabs 为我的 api 创建页面选项卡。当我查询它返回 "success" 时,它已创建(无法找到它的存储位置,但它正在工作......)。 之后,我在我的个人资料上创建了一些数据,用于测试,还在页面上查看 Facebook 是否发送任何更新,它突然发送一个更新,评论我的用户个人资料 post(在时间轴上共享). 响应是:

14:17 05.02.2015
Array
(
    [object] => user
    [entry] => Array
        (
            [0] => Array
                (
                    [uid] => ****my_fb_id****
                    [id] => ****my_fb_id - not_someone_else****
                    [time] => 1423146339
                    [changed_fields] => Array
                        (
                            [0] => feed
                        )

                )

        )

)

所以 Facebook 发送的是空的提要,没关系,可能有一些权限或其他东西,但在那之后我做了更多 posts 和 ppl 评论它(在用户个人资料和测试页面上)但是Facebook 没有发送任何更新,也没有对我的网页进行任何调用。 那么过去有没有人遇到过这个问题,他是如何解决的? 从 Facebook 接收更新的部分是:

$method = $_SERVER['REQUEST_METHOD']; 
    if(isset($_GET['hub_mode']) && isset($_GET['hub_verify_token'])){
          if (trim($method) == 'GET' && trim($_GET['hub_mode']) == 'subscribe' && trim($_GET['hub_verify_token']) == VERIFY_TOKEN) {
            print $_GET['hub_challenge'];
          }
      }
      else if ($method == 'POST') {      
        $updates = json_decode(file_get_contents("php://input"), true); 
            $file = 'log.txt';
            $current = file_get_contents($file);
            @$results = print_r($updates,true);
            $current .=  $results;
            file_put_contents($file, $current);                             
    }

我已尽力详细说明我的问题...搜索过但不太明白为什么它不起作用。

除了使用@CBroe 概述的过时方法外,我认为您有一个误解:Facebook 不会向您发送已更改的数据,但对象(它是 fields/edges)用户对象发生更改

对于页面,您可以自己接收更改(changed_fields 对比 FB 请求中的 changes 字段)。

Once a subscription is successfully created, Facebook will make an HTTP POST request to your callback URL every time that there are changes (to the chosen fields or edges).

这意味着您需要根据从 Facebook 获得的信息对象构造一个单独的请求。在您的示例中,这将是对您用户的提要

的请求
GET /{user_id}/feed

查询最近的更改。