国内主机显示twitter更新达成

其实本来想用RSS来实现的,但是尝试去烧了一下feedburner,没找对地址导致没成功。倒是有点郁闷。
于是很快找到了万戈兄《Wordpress 免插件输出最新 Twitter》,很不错,可惜只能用在国外服务器,我们国内的wordpress咋办呢。。
当然——暗度陈仓是必要的。简单言之,思路就是:国外服务器上建立这么一个php,然后在国内调用其内容。
必要条件:位于国外的空间php一只——其实不少免费空间都挺不错。
步骤如下:
1、在国外服务器上新建一只php,比如test.php,内容就是万戈兄那篇文章中的全部:
- <?php
- // Your twitter username.
- $username = "cntang";
- // Prefix - some text you want displayed before your latest tweet.
- // (HTML is OK, but be sure to escape quotes with backslashes: for example href=\"link.html\")
- // Suffix - some text you want display after your latest tweet. (Same rules as the prefix.)
- $suffix = "";
- $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
- function parse_feed($feed) {
- $stepOne = explode("<content type=\"html\">", $feed);
- $stepTwo = explode("</content>", $stepOne[1]);
- $tweet = $stepTwo[0];
- $tweet = str_replace("<", "<", $tweet);
- $tweet = str_replace(">", ">", $tweet);
- return $tweet;
- }
- $twitterFeed = file_get_contents($feed);
- echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
- ?>
2、在浏览器里面测试http://你的域名/test.php输出正常后,再来改国内wordpress的页面,在你需要的地方放上以下代码:
- <?php echo(file_get_contents('http://你的域名/test.php')); ?>
大功告成。正常输出无极限。问题和原来的方法一样,没有时间码。。
PS:刚折腾完,就在万戈兄的blog上发现《用 FeedBurner 烧制 Twitter feed》一文。立刻杯具的一塌糊涂。回头还是再改改,用RSS貌似可以显示时间码。


















最杯具的地方是不知道怎么登陆上去写,能显示也没有用。。。
[回复这南瓜]爬墙登陆很麻烦,我们这些老骨头爬不动了。