我正在我的主页上显示推特提要:
http://www.fairwaterrights.com
feed工作正常。但如果我点击推特帖子中的链接,它不会打开。
例如,而不是打开http://bit.ly/lNWyT9
在浏览器中,它尝试打开http://www.fairwaterrights.com/%22http:/bit.ly/lNWyT9%22
.
我怎样才能解决这个问题?代码如下:
<?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("<", "<", $feed);
$feed = str_replace(">", ">", $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);
?>
谢谢你的帮助!
SO网友:xLRDxREVENGEx
试试这个。我通过并替换了"
具有\'
/* 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(\'<\', \'<\', $feed);
$feed = str_replace(\'>\', \'>\', $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);
?>