This module provides a core module with an API which other modules can hang off of to provide statistics on any of your favourite social websites.
Currently, this project supports:
Its currently in use at the demo site… Version 2 has also just been released for testing.
Obviously, there will be certain URL patterns which you don't want your block to appear on. usually, this list would begin with the admin pages and the login pages. For example, this is what I have it set to for ThingyMaJig:
This module is still in partially in development, so please test it out before putting it on a live site. It's working for my site, but there are some known bugs that I'm ironing out.
About The Add-ons
Below is a short description about each contributed/add-on module for this project. Currently there are 3.
Del.icio.us is probably the most simple of the modules. You may notice that every bookmark in Del.icio.us has a 32 character code on the end of it which looks uncannily like and MD5. That's quite a coincidence because it IS an MD5 - of the target URL. You may also notice it has an RSS feed too. All this module needs to do is go out there and grab the RSS feed for the current URL and, assuming the server returned a '200 OK' status (rather than 503 or 404, etc) then you can go ahead and parse the XML. Easy!
This is almost the same as Del.icio.us, but has a few key differences. Firstly, their API isn't as public as Del.icio.us - you need to sign up and activate a key for your account. This is the feature which caused me to add the 'settings' operation to the Social Statistics API which allows you to tag extra fields onto the settings page. The other difference is that you don't access by URL, you post data to them and they then return the XML. The Ma.gnolia API is far neater and more organised in my opinion, compared to Del.icio.us - however their servers are a LOT slower (at least from my location).
Digg was possibly the hardest to integrate mainly due to a lack of coherence in their API. It feels like something which has evolved rather than grown in a planned and methodical way. For starters, there is a different URL to submit a new Digg compared to the URL which is required to Digg and existing item (this URL I have yet to decode, so the module currently just sends you to the Digg page for that item). For the first two, the title of the statistic links you to the post page. For Digg, you don't know if you're submitting or digging until you have got the statistic data from the server and, as this is done using AHAH, there is no way to know this at page load time unless the statistics have been previously loaded into cache. This is why the Digg item sometimes has its link on the value and sometimes on the title. I would appreciate thoughts on how to improve this.
AHAH Data Retrieval
The problem I faced during development was that if a particular service was taking its time responding with data, it held up the page load time until it had served up its reply. This isn't really ideal - even with caching, you still had to wait for the initial or updated value. I looked at jQuery and some Drupal core commands, such as drupal_http_request, and was pleasantly surprised at how easy it was. Things are certainly much more interesting with jQuery!
If a statistic is cached (using Drupal's internal caching mechanism) then that data is servered up straight into the block, however if it is not available, then a template entry is added with an animated "ajax loading" style GIF which I generated using a fantastic and free website; http://ajaxload.info/. The function also adds a single line of jQuery which calls a function included with the module which fires off a background HTTP post back to the website. This post induces another one of the Social Statistics API operations, the 'count' which literally returns the value - nothing else at all. This value is then cross-faded with the animation using jQuery (ok, I might have got carried away there).
There are quite a few theme functions provided, so if you don't like the way its lays out its data by default, you should be able to quite easily override it.
I would love to have this project gain a repository of extra social networks. I have personally looked into Stumble Upon, but cannot find a way to get it to return any statistic about the URL in question (favourites, likes, dislikes, etc). Does anyone know of a way?