29
2008

Tips:利用Technorati API在你的Blog显示排名

分享到 Twitter分享到 Twitter 分享到 Google Reader 分享到 Google Reader 分享到 FriendFeed 分享到 FriendFeed

Yoast的Blog上介绍了一个利用Technorati API直接在Blog上显示排名的方法,原文为Using the Technorati API on your blog,此方法与之前介绍过的用字符方式显示Feedburner订阅数的方法类似,同样利用一段代码就可搞定。

个人感觉非常不错,所以马上试验了一下,现已能成功输出相应信息,具体使用方法如下。

1、首先到Technorati上获取你的API Key

2、在Blog模版中添加如下代码:
注:红字部分需改为你自已的值。

<?php $technorati = get_option(“technorati”);
if ($technorati['lastcheck'] < ( mktime() – 600 ) ) {
$apikey = “apikey“;
$endpoint = “http://api.technorati.com/cosmos?key=”.$apikey;
$request = $endpoint.”&url=riku.me&limit=10″;
$snoopy = new Snoopy;
$result = $snoopy->fetch($request);
if ($result) {
$pattern1 = ‘/<inboundblogs>([0-9]+)</inboundblogs>/’;
$pattern2 = ‘/<inboundlinks>([0-9]+)</inboundlinks>/’;
$pattern3 = ‘/<rank>([0-9]+)</rank>/’;
preg_match($pattern1, $snoopy->results, $matches);
preg_match($pattern2, $snoopy->results, $matches2);
preg_match($pattern3, $snoopy->results, $matches3);
$technorati['inboundblogs'] = number_format($matches[1]);
$technorati['inboundlinks'] = number_format($matches2[1]);
$technorati['rank'] = number_format($matches3[1]);
$technorati['lastcheck']= mktime();
update_option(“technorati”,$technorati);
}
}
echo “<p>本Blog最近六个月内在”.$technorati['inboundblogs'].” 个Blog上有
“.$technorati['inboundlinks'].” 个外部链接,
在所有Blog中的排名为 “.$technorati['rank'].” .</p>”; ?>

3、查看自已的Blog显示效果。

本站位于Technorati上的信息:http://technorati.com/blogs/riku.me

Tips:利用Technorati API在你的Blog显示排名   technoratirank

Blog上的显示效果。

Tips:利用Technorati API在你的Blog显示排名   technoratirank2

原作者文章:http://yoast.com/technorati-api-wordpress/

Technorati : , ,

Written by Riku in: 教程技巧 | 标签:, ,
# BackLinks:在你的Blog上出售链接挣取美金,支持Paypal支付, 点此注册!
# 不花一分钱,获取co.cc免费域名

8 条评论 »

RSS feed for comments on this post. TrackBack URL


Leave a Reply

Additional comments powered by BackType

最新文章

分类

存档

Powered by WordPress. Theme: TheBuckmaker. Schuldenfallen, InterTech Blog

Blog Widget by LinkWithin .