脚本宝典收集整理的这篇文章主要介绍了php – Facebook图形API循环通过分页,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我觉得这可能是一个错误,因为如果您选择任何页面,使用access_token查看事件,则无法获取“下一个”分页URL的任何数据.例如在apigee.COM上尝试https://graph.facebook.com/evenightclub/events
有任何想法吗?
($fid是页面对象id)
try { $faceBook = new Facebook(array( 'appId' => '<removed>','secret' => '<removed>',)); $access_token = $facebook->getAccessToken(); $events_data = array(); $offset = 0; $limIT = 5000; $params = array('access_token' => $access_token); //fetch events From Facebook API $data = $facebook->api("$fid/events/?limit=$limit&offset=$offset",$params); $events_data = array_merge($events_data,$data["data"]); //loop through pages to return all results while(in_array("paging",$data) && array_key_exists("next",$data["paging"])) { $offset += $limit; $data = $facebook->api("$fid/events/?limit=$limit&offset=$offset",$params); $events_data = array_merge($events_data,$data["data"]); }}
//loop through pages to return all results while(in_array("paging",$data["paging"])) { $offset += $limit; $data = $facebook->api("$fid/events/?limit=$limit&offset=$offset",$params); // make sure we do not merge with an empty array if (count($data["data"]) > 0){ $events_data = array_merge($events_data,$data["data"]); } else { // if the data entry is empty,we have reached the end,exit the while loop break; } }}
以上是脚本宝典为你收集整理的php – Facebook图形API循环通过分页全部内容,希望文章能够帮你解决php – Facebook图形API循环通过分页所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。