Sat, 29 Mar 08

Reference Trackback Server implementation

To aid my development of the del.icio.us trackbacks firefox extension I created a reference trackback server implementation based on the trackback specification.

It’s written in Ruby as a Mongrel handler and stores the trackbacks serialized to YAML on the filesystem. The code is over in my google code repository (no direct link as I plan to move the trackback-server from its current home in /trunk/scratch to /trunk/www/trackbacks.seagul.co.uk).

On the off-chance that someone else might find it useful I’m currently hosting it at http://trackbacks.seagul.co.uk. You might use it to see the del.icio.us trackbacks extension in action or to test the sending of trackbacks from your blog (the trackback URL is http://trackbacks.seagul.co.uk/trackback). Or, you could just play with it using curl.

# Let's just try to GET the trackback URL
$ curl http://trackbacks.seagul.co.uk/trackback
<?xml version="1.0" encoding="utf-8"?>
<response>
  <error>1</error>
  <message>Http Method MUST be POST</message>
</response>

# OK, so we'll POST to the trackback URL
$ curl http://trackbacks.seagul.co.uk/trackback -X"POST"
<?xml version="1.0" encoding="utf-8"?>
<response>
  <error>1</error>
  <message>Content-Type MUST be 'application/x-www-form-urlencoded' with OPTIONAL character encoding</message>
</response>

# Posting with the correct Content-Type
$ curl http://trackbacks.seagul.co.uk/trackback -X"POST" -H"Content-Type: application/x-wencoded"
<?xml version="1.0" encoding="utf-8"?>
<response>
  <error>1</error>
  <message>You MUST send the URL of your post (permalink) that mentions this post.</message>
</response>

# Post with the correct Content-Type and the required URL parameter to actually have a trackback created on the server
$ curl http://trackbacks.seagul.co.uk/trackback -X"POST" -H"Content-Type: application/x-wencoded" -d"url=http://example.com"
<?xml version="1.0" encoding="utf-8"?>
<response>
  <error>0</error>
</response>