Monday, November 20, 2006

Display Your Technorati Rank

Recently I noticed that Technorati added a link count widget which is pretty cool... but what I really wanted was a widget to display my Technorati rank.

Not finding one, I began poking around the Technorati API, and created my own widget.

Its output looks something like:

PurpleMoggy's Blog
Rank: 271,017 (17 links from 13 blogs)

Basically, the blog name followed by the actual ranking, and a link to your blog's Technorati page.

If anyone else wants to use this then add the following to your page:
<!--
Technorati Rank (technorati.com)
Ducksoup Technorati PHP API Library (kailashnadh.name/ducksoup/)
Created by: PurpleMoggy (purplemoggy.blogspot.com)
-->
<script type="text/javascript" src="http://purplemoggy.clawsorpaws.com/technorati/rank.php?u=*.blogspot.com"></script>

You'll need to replace the part in bold with your blog's url.

The actual HTML output will be something like:
<div class="tec_wrap">
<div class="tec_name">
<a href="http://technorati.com/blogs/http%3A%2F%2Fpurplemoggy.blogspot.com">
PurpleMoggy's Blog
</a>
</div>
<div class="tec_rank">
<a href="http://technorati.com/blogs/http%3A%2F%2Fpurplemoggy.blogspot.com">
Rank: 271,017 (17 links from 13 blogs)
</a>
</div>
</div>

This should let you style it however you want... like I did in my sidebar :)

Finally, I'd like to thank Kailash Nadh for creating Duck Soup, a wonderful Technorati PHP API Library (which basically just meant that I didn't have to parse any XML myself)

Update:
As an example of what you can do with styling rules you could add the following css to your page's header:
div.tec_name {
display:none;
}
div.tec_rank {
background: url(http://static.technorati.com/static/css/img/icn/talkbubble.png) 0 2px no-repeat;
padding-left: 16px;
border:0;
}
div.tec_rank a:link, div.tec_rank a:visited {
color: #390;
text-decoration:none;
}
div.tec_rank a:hover {
border-bottom:1px dotted #390;
}

which would hide the blog name line, and render the Rank line to look very similar to how it's displayed at Technorati.com

Update #2:
I included a small link back to this post. Normally I don't like adding any sort of branding, but I just added a small question mark (?) after the rank which is actually how it's displayed at Technorati anyway. I also wrapped it in a span with a class of tec_link so it is possible to hide if you really want to.

26 comments:

protesto said...

What a great hack. Thanks for sharing. Btw, I've modified Technorati Links Count Widget for blogger beta. Here is the code.

Vivek said...

very useful! very impressive :)

PurpleMoggy said...

Well, this sucks... I just ran into a problem

I'm getting this error now when making API calls:

You have used up your daily allotment of Technorati API queries.

I don't see anything documented saying there's a maximum allotment of API calls anywhere

PurpleMoggy said...

Alright, I updated it to include some caching... you probably won't notice the update (ie. it won't start working) until the 24 hour period starts over

Ramani said...

Good one!

Ramani said...

Hi, I am using this script. It was working fine till yesterday. It suddenly stopped working today and shows my rank as 0. My blog url is hackosphere.blogspot.com. Could you please check?

PurpleMoggy said...

I just tested, and it looks like your blog is showing the count correctly now.

Before I added caching, if there were too many queries it would show up as all 0's

But now if there's too many queries (or any other error) it actually prints the 'too many queries error'. I've wrapped this error message in the tec_wrap and tec_error classes, so it should be easy to hide with css.

The only thing I can think of is that when it searched it didn't find any results. I've noticed Technorati has seemed to be having some issues the last few days. I can search for a blog at one time and it either finds no results or very few results, but if I try a little while later it'll find everything again.

Basically this widget keeps a cached copy of Technorati's results for 24 hours before attempting to get an update (blame Technorati's API for limiting the number of calls per day per API key). So if it did grab results for your blog and return 0's then those 0's would be cached for 24 hours. I'm not sure if there's a way around that (especially if it's Technorati returning bad results).

Ramani said...

Thanks for your explanation. It works now.

Joost de Valk said...

I wrote a Greasemonkey script to do the same for all pages you are visiting. Find it here.

Masey said...

Does this script only work for Blogger sites? I only get zero values when I try to add it to my Wordpress Blog.

http://www.masey.com.au/blog

PurpleMoggy said...

@Masey

Try it now :)

Anonymous said...

I appreciate that you keep your blog going and allow comments. To me feedback is an interesting part of a website.

News

LOUI$$ said...

PM, It suddenly stopped working today and shows my rank as 0. What happen to my widget?

My blog url is bloggingsecret.blogspot.com. Could you please help me?

PurpleMoggy said...

@LOUI$$

My guess would be something like what I told Ramani above. When it searched for your blog Technorati probably just returned 'not found' or all zero's. And now those 0's are cached for 24 hours.

Copiador Descarado said...

Very good!
Thank you.

Culture Shiok! said...

Where have you been all my blogging life!

You make Blogger better!

Thanks!

Shiva said...

Well there is a site (just click the link under that widget) from where u can get directly the url how much ur blog is worth.
But it is better if u r just thinking to boast about
add as much as digits you want to
find the digits in the code and add digits
look out in my blog
http://www.supershiva.blogspot.com

One Wacky Mom said...

Wow, this is awesome. Now I am technologically seriously challenged and I just found you through Ms. Latina so I'm going to try this...but I may be back because there's a good chance I'm going to screw it up! I'm just that pathetic! Or I should say...that old.

iEn said...

thx for the hack.. very interesting :D

tayzar said...

Really Thanks you!! very useful and now I can reduce my blog loading time . Can I translate your post to Myanmar (Burma) Language with your post link?

jdaynger said...

what are the chances of you allowing us access to the php file?

Jeremiah McNichols said...

Awesome.

PurpleMoggy said...

@jdaynger

I know this is kinda late now, but are you still interested in the code?

I'm not sure how many people still use this or not, but is anyone else interested in hosting this?

rawi said...

nice blog

techniqueal techie said...

this is a kewl hack! impressive! =)

xXx said...

Wow! Good job!!!