Blogging API madness

When I was working on the 1.2 release of Killer-Blog I ran into some mess. One of the main improvements is support for blogging API’s, so adding blog entries will be easier when using tools that support these. There are a couple of popular blogging API’s, most of which come from online weblog sites, such as MovableType and Blogger.

The reason for this post that I got kind of frustrated with the documentation on the API’s. They are not clear at all. So far, I implemented two API’s:

  1. Blogger API
    Supported by Blogger.
    The original spec can be found at the Blogger site. The spec is reasonably OK. The API itself is very limited in use. For example, you can add new post entries, but can only specify the body, and not the title.
  2. MetaWeblog API
    Supported by a variety of blogging engine, such as RadioLand and MSN Spaces.
    The original spec is on the XML-RPC site.

Now this last one is bot popular and bad. Here’s two examples:

  • Check these fragments:
    The members of the struct passed in newPost and editPost come from the elements of items in RSS 2.0. The most commonly used core elements have no attributes, so it’s clear how to include them in the struct.
    They have got to be kidding! The RSS 2.0 spec lists all sub-elements of the <item> element. The publication date is called pubDate, whereas the MetaWeblog API expects dateCreated. That’s just one of the places where you are left guessing.
  • Even the existing implementations such as the one for MSN Spaces tend to differ from the spec. Check the sample code at the MSDN site. It shows how the metaWeblog.getCategories implementation returns an struct consisting of a string for the description. But the spec mentions that when passing in categories, you should use an array of strings, and that the metaWeblog.getCategories should return an array of structs, consisting of strings for description, rssUrl and htmlUrl.

Fortunately there are some implementations out there that do help you to determine the form of the API. Go to the web service of the dotnetjunkies weblog and find a pretty nice definition.

As a bonus, here is my definition of the server-side interface you need to implement for your engine to work. You’ll need to download the CookComputing.XmlRpc assembly from Charles Cook to implement the interface. There are some issues with the proxy generation in this library and .NET 2.0 RTM (and betas), but that shouldn’t affect you with this server-side implementation.

[XmlRpcUrl(http://www.yourserverhere.com/yourhandlerendpointhere.ashx)]
public interface
IMetaWeblogApi
{
  [XmlRpcMethod(“metaWeblog.newPost”, Description = “Makes a new post to a designated blog.”)]
  [return: XmlRpcReturnValue(Description = @”Post ID of newly created blog post.”)]
  string NewPost(string blogId, string username, string password, RssItem item, bool publish);

  …
}

File Attachment: MetaWeblogApi.zip (1 KB)

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s