WordPress, MetaWeblogAPI

Back to my project to migrade my blog posts from Community Server to WordPress.

WordPress supports the MetaWeblogAPI.  This API uses XML-RPC.  I started out looking for a Java wrapper for the MetaWeblogAPI, but couldn’t find anything useful.

I found a content management system named Jahai that has a MetaWeblogAPIImpl class, but it doesn’t look like it’s meant to be used standalone. 

There’s a com.sun.labs.tools.blog namespace with some useful classes with names like Blog and MetaWeblogPublisher, which I found in the bloged jar file, but I can’t find any documentation or information on these classes at all.

So what I’ve ended up doing is using the Apache XML-RPC client classes to talk XML-RPC rather than trying to find a higher level interface to it.  It’s a pretty simple protocol, so no big deal.


1
2
3
4
5
6
7
URL blogUrl = new URL("http://my.blog/path.to/xmlrpc.php);
XmlRpcClient xmlrpc = new XmlRpcClient (blogUrl);
Vector params = new Vector ();
params.addElement("blogid");
params.addElement("username");
params.addElement("password");
Object o = xmlrpc.execute ("metaWeblog.getCategories", params);

That gets back an object (a Vector I believe) that contains the categories on my blog.



Next step:  Post something.