Php Facebook API没有拉动所有评论

时间:2016-09-25 07:59:11

标签: php facebook api facebook-requests

我正试图从Facebook页面获取所有评论。但是有些原因,它没有得到所有的评论。

Php代码:

$f1=$fb->get('/me/accounts?access_token='.$user_access_token);
      $id = $f1->getDecodedBody()['data'][0]['id'];
      $access_token = $f1->getDecodedBody()['data'][0]['access_token'];

      $ff1=$fb->get('/'.$id.'/ratings?access_token='.$access_token);

      $facebook_array = $ff1->getDecodedBody()['data'];

      $review = array();
      foreach($facebook_array as $data) {
          $review_text="";
          $pic= $fb->get('/'.$data["reviewer"]["id"].'/picture?access_token='.$access_token)->getHeaders()['Location'];
          if(isset($data['review_text'])){
            $review_text = $data['review_text'];
          }
          $r = array("profile_photo_url"=>$pic,
                 "created_time"=>$data['created_time'],
                 "rating"=>$data['rating'],
                 "reviewer"=>array("name"=>$data['reviewer']['name'],
                                   "id"=>$data['reviewer']['id']),
                 "review_text"=>$review_text);
          array_push($review,$r);
      }

1 个答案:

答案 0 :(得分:-1)

只需添加限制参数即可。 ?极限= 9999

$f1=$fb->get('/me/accounts?access_token='.$user_access_token);
      $id = $f1->getDecodedBody()['data'][0]['id'];
      $access_token = $f1->getDecodedBody()['data'][0]['access_token'];

      $ff1=$fb->get('/'.$id.'/ratings?limit=100&access_token='.$access_token);

      $facebook_array = $ff1->getDecodedBody()['data'];

      $review = array();
      foreach($facebook_array as $data) {
          $review_text="";
          $pic= $fb->get('/'.$data["reviewer"]["id"].'/picture?access_token='.$access_token)->getHeaders()['Location'];
          if(isset($data['review_text'])){
            $review_text = $data['review_text'];
          }
          $r = array("profile_photo_url"=>$pic,
                 "created_time"=>$data['created_time'],
                 "rating"=>$data['rating'],
                 "reviewer"=>array("name"=>$data['reviewer']['name'],
                                   "id"=>$data['reviewer']['id']),
                 "review_text"=>$review_text);
          array_push($review,$r);
      }