我在php中有一个函数,它列出了twitter中用户的关注者。当我使用chrome导航到保存该功能的页面时,它可以工作,有时则不然。
Chrome在5次中有3次出现“错误330(net :: ERR_CONTENT_DECODING_FAILED):未知错误”
Mozilla在提供“内容编码错误”
之前的5次中有4次工作Opera显示了这个
警告:为foreach()提供的参数无效 1639行的C:\ wamp \ www \ ntwyt \ core \ common \ twitter.php j&x o 4 a h RA N T。& Km n 5ýi <Т K /o4¨b@ý
这是代码
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;
}
问题是什么?它有效并且不起作用。
答案 0 :(得分:0)
我想你想循环:
foreach ($feed->users as $user) {
....
}