Using the s.coop URL shortening service with a Drupal powered website

I like to use the excellent URL shortening service s.coop, but how can I easily integrate that into a Drupal website?

There is an excellent Drupal module, that works for both Drupal 6 and Drupal 7 websites, called Shorten URL (http://drupal.org/project/shorten). It provides the ability to utilise shortened URLs, and because it offers the ability to add a custom shortening service, that includes s.coop.

The module works with a number of other Drupal modules to provide shortened URLs. I use it with the Twitter module, which enables authorised users of the Drupal website to send tweets directly from the website when they create or update content on the site. The Twitter module will automatically make use of any service set up using the Shorten URL module, so once you have the Twitter module up and running, you simply need to install and enable the Shorten URL module (actually a group of modules).

As s.coop is not set up as one of the default list of shortening services, you will need to create a new custom service, at http://www.example.com//admin/settings/shorten/custom (swap out 'example.com' for your own website address).

Give the custom service a name (something like s.coop works well), and set the API endpoint URL. The Shorten module supports text or plain responses, as well as XML and JSON format responses. I opt for text, which works fine for my needs, so I need to include the relevant parameter in the API endpoint URL. For s.coop this parameter is "$format=simple", so my full endpoint URL is:
http://s.coop/devapi.php?action=shorturl&format=simple&url=
Take a look at http://s.coop/usage.php for more on this.

Save the setting.

Err, that's all. It works.