最近在做一个WP插件,需要用到一些博客的排名等信息,ALEXA也提供,Technorati也有,但权衡一下,还是决定用Technorati的数据更好。Technorati是一家比较专注于WEB2.0的博客网站,它提供了博客搜索、博客排名、反向链接搜索、TAG归类搜索等服务。相比Alexa的工具条统计,它依据博客的反向链接等数据进行排名,数据更加客观。
选择Technorati更重要的是Technorati提供了完整的API接口以供应用,虽然ALEXA也提供了接口,却是要收费的,似乎是千次查询$0.1,这让大多数非商业应用的人无法接受。当然Alexa也有几个工具栏的接口被破解后可以盗用,不过个人认为Technorati的数据质量要好于Alexa,决定在插件中使用Technorati的数据。
使用Technorati,先要注册一个Technorati账户,接着访问http://technorati.com/developers/apikey.html,免费获取一个API KEY 如 dfe71294d89ebbca982c98ecd73c96d5 ,正常情况下,一个API KEY每天可以查询500次,这对于一个WP插件应该是足够应用了。
如何应用?Technorati提供了包括博客信息,博客搜索,博客反向链接在内的多种搜索服务的接口,可以访问这里获得更多信息。
以我需要用到的博客信息为例
访问http://api.technorati.com/bloginfo?key=[apikey]&url=[blog url],其中[apikey]替换为API KEY,[blog url]就是要查询的博客URL,如 http://photozero.net (http:// 可省略),在PHP文件中用 file_get_contents() 或 fsockopen() 等方式访问,获取返回内容如:
- <?xml version="1.0" encoding="utf-8"?>
- <!-- generator="Technorati API version 1.0" -->
- <!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml">
- <tapi version="1.0">
- <document>
- <result>
- <url>http://photozero.net</url>
- <weblog>
- <name>零号相册</name>
- <url>http://photozero.net</url>
- <rssurl>http://photozero.net/feed/rss/</rssurl>
- <atomurl>http://photozero.net/feed/</atomurl>
- <inboundblogs>16</inboundblogs>
- <inboundlinks>23</inboundlinks>
- <lastupdate>2008-07-20 03:52:34 GMT</lastupdate>
- <rank>446726</rank>
- <authors>
- </authors>
- </weblog>
- <inboundblogs>16</inboundblogs>
- <inboundlinks>23</inboundlinks>
- </result>
- </document>
- </tapi>
这里面包括了博客名,博客URL,博客排名,博客RSS地址,反向链接等多种信息,是不是很齐全?
再来一个博客TAG搜索的示范,显示你的博客里有哪些热门TAG,访问
http://api.technorati.com/blogposttags?key=[apikey]&url=[blog URL]
照例把[apikey]替换为API KEY,把[blog URL]替换为 http://photozero.net,就会返回我的博客中的TAG(分类也算在TAG里面了)
- <?xml version="1.0" encoding="utf-8"?>
- <!-- generator="Technorati API version 1.0 /blogposttags" -->
- <!DOCTYPE tapi PUBLIC "-//Technorati, Inc.//DTD TAPI 0.02//EN" "http://api.technorati.com/dtd/tapi-002.xml">
- <tapi version="1.0">
- <document>
- <result>
- <querycount>20</querycount>
- </result>
- <item>
- <tag>Free Talk</tag>
- <posts>17</posts>
- </item>
- <item>
- <tag>wordpress</tag>
- <posts>13</posts>
- </item>
- <item>
- <tag>Free_talk</tag>
- <posts>9</posts>
- </item>
- <item>
- <tag>Plugin</tag>
- <posts>7</posts>
- </item>
- <item>
- <tag>WAP</tag>
- <posts>6</posts>
- </item>
- <item>
- <tag>PHP</tag>
- <posts>5</posts>
- </item>
- <item>
- <tag>Server</tag>
- <posts>4</posts>
- </item>
- <item>
- <tag>Mobile</tag>
- <posts>3</posts>
- </item>
- <item>
- <tag>Baidu</tag>
- <posts>2</posts>
- </item>
- <item>
- <tag>Blog</tag>
- <posts>2</posts>
- </item>
- <item>
- <tag>Google</tag>
- <posts>2</posts>
- </item>
- <item>
- <tag>Javascript</tag>
- <posts>2</posts>
- </item>
- <item>
- <tag>Yahoo</tag>
- <posts>2</posts>
- </item>
- <item>
- <tag>chinese</tag>
- <posts>2</posts>
- </item>
- <item>
- <tag>DreamHost</tag>
- <posts>2</posts>
- </item>
- <item>
- <tag>web20</tag>
- <posts>1</posts>
- </item>
- <item>
- <tag>Ajax</tag>
- <posts>1</posts>
- </item>
- <item>
- <tag>Apple</tag>
- <posts>1</posts>
- </item>
- <item>
- <tag>iPhone</tag>
- <posts>1</posts>
- </item>
- <item>
- <tag>IP</tag>
- <posts>1</posts>
- </item>
- </document>
- </tapi>
好了,其他几种应用就不多介绍了,如果有需要应用相关服务的不妨一试。这里推荐一个老外Kailash Nadh写的Technorati API应用的PHP类——Duck Soup,到他主页下载这个库,里面包含了一个应用范本,用这个代码就可以轻松应用Technorati服务了,不用再自己弄一些fsockopen的下载类了。


哈哈,你真有激情啊,一直连续不断做插件,我支持你,这个插件出来了我一定使用
如果你有什么插件创意就告诉我