使用以下代码显示我的推特个人资料中的朋友列表.
我喜欢一次只加载一定数量,比如说20,然后在第一个1-2-3-4-5的底部提供分页链接(不过很多除以限制)最后
$xml = simplexml_load_string($rawxml);
foreach ($xml->id as $key => $value)
{
$profile = simplexml_load_file("https://twitter.com/users/$value");
$friendscreenname = $profile->{"screen_name"};
$profile_image_url = $profile->{"profile_image_url"};
echo "$friendscreenname
";
}
******更新******
if (!isset($_GET['i'])) {
$i = 0;
} else {
$i = (int) $_GET['i'];
}
$limit = $i + 10;
$rawxml = OauthGetFriends($consumerkey, $consumersecret, $credarray[0], $credarray[1]);
$xml = simplexml_load_string($rawxml);
foreach ($xml->id as $key => $value)
{
if ($i >= $limit) {
break;
}
$i++;
$profile = simplexml_load_file("https://twitter.com/users/$value");
$friendscreenname = $profile->{"screen_name"};
$profile_image_url = $profile->{"profile_image_url"};
echo "$friendscreenname
";
}
echo "Next 10
";
这是有效的,只需要从$i开始抵消输出.思考array_slice?