$facebook = new Facebook(array(
'appId'=>'','secret'=>''
));
$post = "10152390205162139";
$comments = array();
$done = false;
$options = array();
$path = "/".$post.'/comments';
while(!$done){
try{
$data = $facebook->api($path,'GET',$options);
}catch(FacebookApiException $e){
echo $e->getMessage();
$data = null;
$done = true;
}
if(!is_null($data)){
$comments = array_merge($comments, $data['data']);
if(isset($data['paging']['next']) && !empty($data['paging']['next'])){
$parts = parse_url($data['paging']['next']);
$path = $parts['path'];
parse_str($parts['query'], $options);
} else {
$done = true;
}
}
}
我想要做的是,从页面的特定帖子中提取评论列表,现在我想限制评论的数量,如100或200,因为一些帖子的评论超过50k,它杀了我的剧本:\
答案 0 :(得分:1)
答案 1 :(得分:0)
您可以尝试限制脚本中的while
子句,例如:
while (!$done || count($comments) <= 200) {
...
}