<?php
// 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(“<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);
?>
总结一下这个方法的特点:
1、非插件.
2、不用验证用户名和密码,也就是说你可以指定调用任何一个人的 tweet.
3、可以自定义 tweet 信息后显示的文字,就是 $suffix = “”; 这里.
4、只能调用最新的一条 tweet,刚好满足我的需求。
5、大概只有国外空间才能使用.(经我验证,确实如此)
11.wordpress 非插件调用评论表情
<!–smilies–>
<?php
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 = “<img src=”{$file}” alt=”{$smile}” />”;
$imglink = htmlspecialchars($img);
$link .= “<a href=”#commentform” title=”{$smile}” onclick=”document.getElementByIdx_x(‘comment’).value += ‘{$value}’”>{$img}</a> ”;
}
echo ‘<div class=”wp_smilies”>’.$link.’</div>’;
}
?>
<?php wp_smilies();?>
将以上代码复制到 comments.php 中合适的位置。