Technorati API

All of the examples of utilizing the Technorati API are pretty old… PHP has really evolved since the code examples that they’ve provided. When I first started looking for some code samples of utilizing PHP5+ for parsing XML, I had a hard time finding some. SimpleXML is an incredible advance in parsing XML with PHP – it’s awesome.

I’m surprised that I don’t see more examples of developing widgets and functions with Technorati, perhaps some of it is because the original examples are so old.

With that in mind, I built a simple page that can be used to retrieve your technorati rank. It can be used seamlessly where ever you would like it (as long as you can execute JavaScript in your page). I use the CURL library to connect to the API and then parse the XML using SimpleXML. I then have a simple JavaScript reference to execute the page to display the rank where I would like it.

There are 3 responses from the code:

  1. Error – you’ll receive this if you’re looking up a domain other than your own or if the API returns any type of error. This way no one can hijack your widget and drive you into the Daily Allotment of API calls.
  2. Rank – this will give you the rank of your blog with a link to the search page to bring up your page’s information on Technorati.
  3. Add to Favorites – this link will appear if you run into any kind of error, such as the Daily Allotment of API calls.

Adding and hosting the Widget Code on your Site:

If you’d like to use the widget on your site, be sure to host the code on your site and update the following script to access it. If you point to my page, you’ll just get an error with a link back to this page.

To Install:

  1. Copy the code and save it to rank.php on your website in a directory of your choosing.
  2. Update the code with your API key and your domain.
  3. Place the javascript below in your sidebar or where ever you would like it displayed. Be sure to update both the path and the url you wish to look up.

Support this Project: