BlogEngine.Net supports XMLRPC and the MetaWeblog API. This allows it to support other tools like Windows Live Writer. But where are the specifications for the API and WLW found? I came across some interesting related links along the way in trying to figure out how to add proper slug support for pages in BlogEngine.Net.
WordPress outlines the definitive guide to the WordPress API at http://codex.wordpress.org/XML-RPC_wp. This includes:
- wp.getTags
- wp.getPage
- wp.getPages
- wp.newPage
- wp.deletePage
- wp.editPage
- wp.getCategories
- wp.getAuthors
Several other API’s are listed on the site. The reference is the only tool I’ve found that outlines the structures used for XMLRPC for the MetaWeblog API.
Windows Live Writer outlines the list of all the options, capabilities supported between the MetaWeblog, MoveableType, and Wordpress systems in their article Defining Weblog Capabilities with the Options Element.
In BlogEngine.Net the Windows Live Writer manifest is defined in the file wlwmanifest.xml. This can be extended to support some of the additional options supported by WLW. However, additional code is required in the BlogEngine.Net XMLPCRequest, XMLRPCResponse and MetaWeblog files to support these features.
One of the interesting design decisions about BlogEngine.Net is that it supports XML files and uses a Guid as the ID for all posts and pages. The MetaWeblog API wants to use an int for the ID. This causes some unexpected results when selecting a parent, or the author in page editing mode with WLW. This is just a design tradeoff of not using a database (sequential ID’s are difficult and cumbersome to generate without a database).
Interestingly enough, there is an unusual nuance either in the API or WLW, in that in order to get a hierarchical indented list in the dropdown list of pages, XMLRPCResponse.WriteShortPages needs to set the wp_page_parent_id to the “title” and the page_parent_id to the “guid” of the page. It seems a bit backwards to me.
I’ve extended the MetaWeblog API in BlogEngine.Net to support slugs properly. The trick was using value wp_slug in the XML for the same as the post code does.
Code added from XMLRPCResponse.WritePage and WritePages. The MWAPage class must also add the slug properly to support this.
// wp_slug
data.WriteStartElement("member");
data.WriteElementString("name", "wp_slug");
data.WriteStartElement("value");
data.WriteElementString("string", _page.slug);
data.WriteEndElement();
data.WriteEndElement();
I’ve published the changes to the MetaWeblog API but keep in mind these changes go way beyond just this change and break compatibility with BlogEngine.Net.
Download: MetaWebLog.zip (15.98 kb). Includes XMLRPCRequest, XMLRPCResponse, and MetaWeblog changes.