直到今天,我一直在使用以下代码在他们的网站上显示客户的“最新推文”:
<?php
// Your twitter username.
$username = "CLIENTTWITTER";
// 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\")
$prefix = "";
// 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);
?>
然而今天,它已经停止工作。我假设,也许是不正确的,这是由于 Twitter 的 API 发生了变化,而且他们已经取消了 v1.0 的插件。
有谁知道可以使用当前 API 的上述代码的良好替代品?如果可能的话,不想添加任何额外的代码。尝试了一些但没有成功。Twitter 开发页面让我非常困惑。
提前感谢您的帮助。