// Your twitter username.
$username = “wange1228″;
// 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(“”, $feed);
$stepTwo = explode(“”, $stepOne[1]);
$tweet = $stepTwo[0];
$tweet = str_replace(“<”, “
$tweet = str_replace(“>”, “>”, $tweet);
return $tweet;
}
$twitterFeed = file_get_contents($feed);
echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
?>
总结一下这个方法的特点:
1、非插件.
2、不用验证用户名和密码,也就是说你可以指定调用任何一个人的 tweet.
3、可以自定义 tweet 信息后显示的文字,就是 $suffix = “”; 这里.
4、只能调用最新的一条 tweet,刚好满足我的需求。
5、大概只有国外空间才能使用.(经我验证,确实如此)
11.wordpress 非插件调用评论表情
function wp_smilies() {
global $wpsmiliestrans;
if ( !get_option(‘use_smilies’) or (empty($wpsmiliestrans))) return;
$smilies = array_unique($wpsmiliestrans);
$link=”;
foreach ($smilies as $key => $smile) {
$file = get_bloginfo(‘wpurl’).’/wp-includes/images/smilies/’.$smile;
$value = ” “.$key.” “;
$img = “”;
$imglink = htmlspecialchars($img);
$link .= “{$img} ”;
}
echo ‘
}
?>
将以上代码复制到 comments.php 中合适的位置。