1

wordpress 侧边栏上的所有 twitter 状态更新都有 bit.ly 链接。当我点击它们时,我得到了 404 页面,因为它不是去bit.ly/uniquenumber,而是尝试去 www.domain.com/blog/“http://bit.ly/uniquenumber/ ”和 www.domain.com /blog 是 wordpress 博客的主页。

有没有一种简单的方法可以阻止它添加 www.domain.com/blog 和引号并将我们带到实际链接?

任何帮助,将不胜感激。这是代码:

/* 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);  
4

2 回答 2

1

如果您要链接到www.domain.com/blog/"http://bit.ly/uniquenumber/",那是因为在位 url 的开头有一个额外的 "。如果 url 没有以定义的协议(http、https、ftp 等)开头,浏览器会将其附加到当前文件夹。

于 2010-01-13T17:14:04.157 回答
0

在没有看到代码并根据您的评论判断的情况下,看起来链接在生成链接的任何插件上都是格式错误的,可能没有正确引用,这就是它们出现在 URL 中的原因。

于 2010-01-13T15:07:34.780 回答