小工具中的Twitter链接不起作用?

时间:2011-05-24 作者:Diane

我正在我的主页上显示推特提要:

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("&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);
?>
谢谢你的帮助!

1 个回复
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&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);
?>

结束

相关推荐

jquery bookmark links

我在jQuery中获得了社交书签,但如何在这段代码中获得帖子标题和永久链接?如果我把<?php echo get_permalink(); ?> 在那里,整个网站都是空白的。$(\'a[rel=shareit-twitter]\').attr(\'href\', \'http://twitter.com/home?status=\' + title + \'%20-%20\' + title); 更新时间:以下是书签的整个jQuery:<script type=\"text/j