从facebook api获取反应

时间:2017-09-08 09:39:04

标签: php facebook facebook-graph-api

您好我从页面获取后期反应有问题,我正在使用facebook sdk,似乎我无法获得反应数据我不知道为什么但是如果我使用facebook的图表浏览器一切都好,它返回反应数据 这是我的要求:

$fb = new Facebook;
$accessToken = 'XXXXX';

$oAuth2Client = $fb->getOAuth2Client();
$all_posts = array();

$fb->setDefaultAccessToken($accessToken);
$fb_data = $fb->get('/101800100890/posts?fields=from,message,description,type,created_time,link,reactions.limit(0).summary(true),full_picture&limit=100&since=2017-09-06&until=2017-09-07')->getGraphEdge(); 

if($fb->next($fb_data)){
$posts_array = $fb_data->asArray();
  $all_posts = array_merge($posts_array, $all_posts );
  while($fb_data = $fb->next($fb_data)){
    $posts_array = $fb_data->asArray();
    $all_posts = array_merge($posts_array, $all_posts );
  }
}
else{
  $posts_array = $fb_data->asArray();
  $all_posts = array_merge($posts_array, $all_posts);
} 

结果:

array:30 [▼
  0 => array:8 [▼
    "from" => array:2 [▼
      "name" => "Thrillist"
      "id" => "101800100890"
    ]
    "message" => "You control the speed on this one-man roller coaster."
    "type" => "video"
    "created_time" => DateTime {#276 ▼
      +"date": "2017-09-06 23:10:00.000000"
      +"timezone_type": 1
      +"timezone": "+00:00"
    }
    "link" => "https://www.facebook.com/Thrillist/videos/10155638274605891/"
    "reactions" => []  ( <==== EMPTY DATA )
    "full_picture" => "https://scontent.xx.fbcdn.net/v/t15.0-10/21450032_10155638282725891_682057810380324864_n.jpg?oh=4cc982a1dfb4af55e94404c1a1630b61&oe=5A5F7641"
    "id" => "101800100890_10155638274605891"
  ]
  1 => array:9 [▼
    "from" => array:2 [▼
      "name" => "Thrillist"
      "id" => "101800100890"
    ]
    "message" => "Nice."
    "description" => "Nice."
    "type" => "link"
    "created_time" => DateTime {#280 ▼
      +"date": "2017-09-06 22:10:00.000000"
      +"timezone_type": 1
      +"timezone": "+00:00"
    }
    "link" => "https://www.thrillist.com/news/nation/weatherman-farts-on-live-tv?utm_source=facebook&utm_medium=social&utm_campaign=thrillist"
    "reactions" => [] ( <==== EMPTY DATA )
    "full_picture" => "https://external.xx.fbcdn.net/safe_image.php?d=AQDP3SisD1D77qyv&url=https%3A%2F%2Fassets3.thrillist.com%2Fv1%2Fimage%2F2699891%2Fsize%2Ftmg-facebook_social.jpg&_nc_hash=AQC3ABIDoywoFXbI"
    "id" => "101800100890_10155638892870891"
  ]

0 个答案:

没有答案