【问题标题】:firefox: bit.ly links in the sidebar of a customised wordpress blog gives a 404 errorfirefox:自定义 wordpress 博客侧边栏中的 bit.ly 链接给出 404 错误
【发布时间】:2010-01-18 14:36:24
【问题描述】:

我在博客的侧边栏上显示了 Twitter 状态更新,通常也有 bit.ly 或 ow.ly 链接。但是每次我在 Firefox 浏览器中单击它时,它都会给我一个 404 错误,因为它会尝试使用以下 url:www.domain.com/blog/"http://bit.ly/uniquenumber" 而不是 bit.ly/uniquenumber。

我刚刚检查了一下,它似乎可以在 mac 上的 google chrome 上运行,但在 mac os x 上的 firefox 上却不行。有没有其他人有类似的问题。

以下是接收推特状态更新的代码:

/* These prefixes and suffixes will display before and after the entire block of tweets. */  
    $prefix = ""; // Prefix - some text you want displayed before all your tweets.  
    $suffix = ""; // Suffix - some text you want displayed after all your tweets.  
    $tweetprefix = ""; // Tweet Prefix - some text you want displayed before each tweet.  
    $tweetsuffix = "<br \><br \>"; // Tweet Suffix - some text you want displayed after each tweet.  

    $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1" . $limit;  

    function parse_feed($feed, $prefix, $tweetprefix, $tweetsuffix, $suffix) {  

    $feed = str_replace("&lt;", "<", $feed);  
    $feed = str_replace("&gt;", ">", $feed);  
    $clean = explode("<content type=\"html\">", $feed);  

    $amount = count($clean) - 1;  

    echo $prefix;  

    for ($i = 1; $i <= $amount; $i++) {  
    echo $tweetsuffix;
    $cleaner = explode("</content>", $clean[$i]);  
    echo $tweetprefix;  
    echo $cleaner[0]; echo $suffix; echo $tweetsuffix;  ?>

    <img src="<?php echo get_bloginfo('template_directory');?>/images/side.png" alt="A line dividing the twitter updates and the open courses listing">
    <?php 
    }    
    echo $suffix;  
    }  

    $twitterFeed = file_get_contents($feed);  
    parse_feed($twitterFeed, $prefix, $tweetprefix, $tweetsuffix, $suffix); 

【问题讨论】:

  • 你能发布你的应用程序的确切输出吗? (即:这回声的原始来源)
  • 听起来链接不正确。对于 html 链接,它必须采用以下格式:mywebsite.commywebsite.com 是否有机会发布 Twitter 提要的原始输出?
  • 感谢 David,如果您有兴趣,请查看 mattbasta 的回答。
  • 很高兴你能把它整理出来:)

标签: firefox wordpress twitter hyperlink bit.ly


【解决方案1】:

为您解决。改变这个:

$feed = str_replace("&lt;", "<", $feed);  
$feed = str_replace("&gt;", ">", $feed);  

到这里

$feed = str_replace("&lt;", "<", $feed);  
$feed = str_replace("&gt;", ">", $feed);  
$feed = str_replace("&quot;", '"', $feed);  

【讨论】:

    猜你喜欢
    • 2023-03-22
    • 2013-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-29
    • 2011-03-27
    • 2013-01-21
    • 1970-01-01
    相关资源
    最近更新 更多