Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am displaying a twitter feed on my homepage:

http://www.fairwaterrights.com

The feed works fine. But if I click on a link in the twitter post, it doesn't open.

For instance, instead of opening http://bit.ly/lNWyT9 in the browser, it tries to open http://www.fairwaterrights.com/%22http:/bit.ly/lNWyT9%22.

How can I fix this? Here is the code:

<?php
$username = "fairwaterrights"; // Your twitter username.
$limit = "4"; // Number of tweets to pull in.

/* 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 = "@fairwaterrights "; // 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=" . $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++) {
$cleaner = explode("</content>", $clean[$i]);
echo $tweetprefix;
echo $cleaner[0];
echo $tweetsuffix;
}

echo $suffix;
}

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

Thanks for your help!

share|improve this question
    
is this a plugin you're using? if so, which one is it? –  NW Tech May 24 '11 at 22:37
    
It's not a plug in, just the code above. –  Diane May 24 '11 at 22:45
    
This code is very similar to yours. Maybe you can compare to figure out the problem –  NW Tech May 24 '11 at 22:52
    
Thanks for the response. That gives me an error message: > Warning: > file_get_contents(search.twitter.com/search.atom?q=from:fairwaterrights&rpp=) > [function.file-get-contents]: failed > to open stream: HTTP request failed! > HTTP/1.1 403 Forbidden in > /home/coltrane22/fairwaterrights.com/wordpress/wp-content/themes/BLANK-Theme/sid‌​ebar.php > on line 86 Line 86 is: parse_feed($twitterFeed, $prefix, $tweetprefix, $tweetsuffix, $suffix); –  user5658 May 25 '11 at 2:33
add comment

1 Answer 1

Try this out. I went through and replaced " with '

/* 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 = "@fairwaterrights&nbsp;"; // 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=' . $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++) {
$cleaner = explode('</content>', $clean[$i]);
echo $tweetprefix;
echo $cleaner[0];
echo $tweetsuffix;
}

echo $suffix;
}

$twitterFeed = file_get_contents($feed);
parse_feed($twitterFeed, $prefix, $tweetprefix, $tweetsuffix, $suffix);
?>
share|improve this answer
    
Further testing show the code works fine in Safari, it is only a problem in Firefox. Any idea why? –  user5690 May 25 '11 at 18:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.