我在php中有一个函数,它列出了twitter中用户的关注者。当我使用chrome浏览器导航到包含该功能的页面时,它工作,有时它不工作。
Chrome工作3的5次之前,它给出"Error 330 (net:: err_content_decooding_failed): Unknown Error "
Mozilla在给出"Content Encoding Error"之前5次有4次是正确的
Opera显示这个
警告:为foreach()提供的参数无效C:'wamp'www'ntwyt'core'common'twitter.php on line 1639�j& x���o��4����h��RA N�����T。amp; N���公里5 y我�& lt;Тb K���/o4�¨��Y @������
下面是代码
function theme_followers($feed, $hide_pagination = false) {
$rows = array();
if (count($feed) == 0 || $feed == '[]') return '<p>No users to display.</p>';
foreach ($feed->users->user as $user) {
$name = theme('full_name', $user);
$tweets_per_day = twitter_tweets_per_day($user);
$last_tweet = strtotime($user->status->created_at);
$content = "{$name}<br /><span class='about'>";
if($user->description != "")
$content .= "Bio: " . twitter_parse_tags($user->description) . "<br />";
if($user->location != "")
$content .= "Location: {$user->location}<br />";
$content .= "Info: ";
$content .= pluralise('tweet', $user->statuses_count, true) . ", ";
$content .= pluralise('friend', $user->friends_count, true) . ", ";
$content .= pluralise('follower', $user->followers_count, true) . ", ";
$content .= "~" . pluralise('tweet', $tweets_per_day, true) . " per day<br />";
$content .= "Last tweet: ";
if($user->protected == 'true' && $last_tweet == 0)
$content .= "Private";
else if($last_tweet == 0)
$content .= "Never tweeted";
else
$content .= twitter_date('l jS F Y', $last_tweet);
$content .= "</span>";
$rows[] = array('data' => array(array('data' => theme('avatar', theme_get_avatar($user)), 'class' => 'avatar'),
array('data' => $content, 'class' => 'status shift')),
'class' => 'tweet');
}
$content = theme('table', array(), $rows, array('class' => 'followers'));
if (!$hide_pagination)
$content .= theme('list_pagination', $feed);
return $content;
}
怎么了?
我认为你想循环:
foreach ($feed->users as $user) {
....
}