Chrome、Opera、Mozilla 内容解码失败

发布于 2024-11-24 21:55:46 字数 2342 浏览 1 评论 0原文

我在 php 中有一个函数,它列出了 Twitter 中用户的关注者。当我使用 chrome 导航到包含该功能的页面时,它可以工作,有时却不能。

Chrome 工作 5 次中有 3 次后,出现“错误 330 (net::ERR_CONTENT_DECODING_FAILED):未知错误”

Mozilla 工作 5 次后出现 4 次,然后出现“内容编码错误”

Opera 显示此信息

警告:为 foreach() 提供的参数无效 C:\wamp\www\ntwyt\core\common\twitter.php 第 1639 行 �j&x���o�4�a �h��RA�N���T.&�Km�n� 5ý i�<Т K���/o4��b�@�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;
}

有什么问题吗?它有效和无效。

I have a function in php, which lists followers of a user in twitter. When I use chrome to navigate to the page which holds the function, It works, sometimes it doesn't.

Chrome works 3 out of 5 times before it gives "Error 330 (net::ERR_CONTENT_DECODING_FAILED): Unknown error"

Mozilla works 4 out of 5 times before it gives "Content Encoding Error"

Opera shows this

Warning: Invalid argument supplied for foreach() in
C:\wamp\www\ntwyt\core\common\twitter.php on line 1639
�j&x���o��4�a ���h��RA�N����T.&�Km�n� 5ý i�<Т
K���/o4�¨�b�@�Y�����

Here's the code

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;
}

Whats the problem? It works and doesn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

胡大本事 2024-12-01 21:55:46

我想你想循环:

foreach ($feed->users as $user) {
    ....
}

I think you want to loop:

foreach ($feed->users as $user) {
    ....
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文