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.
There are 3 responses from the code:
- 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.
- 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.
- 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.
- Copy the code and save it to rank.php on your website in a directory of your choosing.
- Update the code with your API key and your domain.