views:

40

answers:

3

All the twitter status updates on the wordpress sidebar have bit.ly links. When I click on them, I get the 404 page because instead of going bit.ly/uniquenumber it tries to go www.domain.com/blog/"http://bit.ly/uniquenumber/" with www.domain.com/blog being the homepage for the wordpress blog.

Is there an easy way to stop it from adding www.domain.com/blog and quotes and taking us to the actual link?

Any help would be appreciated. Here is the code :

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

without seeing the code and judging by your comment, it looks like the links are malformed on whatever plug-in is generating the links, probably not quoted right, which is why they are showing up in the URL.

GSto
+1  A: 

If you're link is going to www.domain.com/blog/"http://bit.ly/uniquenumber/", it's because there's an extra " at the start of the bitly url. If a url doesn't start with a defined protocol (http, https, ftp etc) the browser will append it to the current folder.

adam
Do you have tips on how to fix it?
strangeloops
The url in the tweet status update does contain http:// at the beginning of the link.
strangeloops
The quote mark might not be *in* the url, but somewhere leading up to that point in your code you are outputting it.
adam
A: 

I just checked it and it seems to work on google chrome on mac but not on firefox on mac os x. Does anybody else have to have the same problem?

strangeloops