Skip to content

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

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

technoratirank.jpg

Blog上的显示效果。

technoratirank2.jpg

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

Technorati : , ,

Related Posts with Thumbnails

7 Comments

  1. Mao wrote:

    这个不错啊…回头试试

    回复回复
    星期三, 十月 29, 2008 at 2:56 下午 | Permalink
  2. 自然堂 wrote:

    又学习了。。。

    回复回复
    星期三, 十月 29, 2008 at 3:19 下午 | Permalink
  3. 大仙 wrote:

    呵呵,这个有意思,学习了!

    回复回复
    星期三, 十月 29, 2008 at 4:43 下午 | Permalink
  4. sofish wrote:

    我的排名好像一直在下滑,比较神奇,不像alexa…

    回复回复
    星期六, 十一月 1, 2008 at 10:44 上午 | Permalink
  5. colortext wrote:

    这个能在博客大巴上用吗?

    回复回复
    星期五, 十一月 21, 2008 at 6:17 上午 | Permalink
  6. colortext wrote:

    只需要改apikey、apikey、riku.me这3个值是吗?

    回复回复
    星期五, 十一月 21, 2008 at 6:22 上午 | Permalink
  7. Riku wrote:

    改前面一个apikey和riku.me就可以了。

    回复回复
    星期五, 十一月 21, 2008 at 8:55 上午 | Permalink

One Trackback/Pingback

  1. waakee.com on 星期三, 十月 29, 2008 at 2:20 下午

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

    作者:Riku
    Yoast的Blog上介绍了一个利用Technorati API直接在Blog上显示排名的方法,原文为Using the Technorati API on your blog,此方法与之前介绍过的用字符方式显示Feedburner订阅数的方法类似,同样利…

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*