【发布时间】:2012-08-01 18:06:10
【问题描述】:
我在下面的代码中遇到问题,有人可以解决吗? 这是我的代码说明:
$friends=get_data(https://graph.facebook.com/".$facbookid."/friends?access_token=".Useraccess_token);
这是 get_data 函数,它返回适当的数据:
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
然后我使用 JSON SERVICE:
$json = new Services_JSON();
$friends = $json->decode($friends);
echo "print data".$friends->data;
if (isset($friends->data))
{
foreach($friends->data as $friend)
{
$i++;
$friendList[] = $friend->id;
}
}
问题是,当我只有 1000 个朋友时,它正在检索数据。但是朋友超过1000就不行了。
事实上,我用过$friends = $json->decode($friends,true); 等。
谁能帮帮我?
【问题讨论】:
-
您使用的是什么 php 版本?自 v5.2 起,通过
json_decode()进行本机 JSON 解码已包含在 php 中。 us3.php.net/manual/en/function.json-decode.php
标签: php facebook facebook-graph-api developer-tools