BuySellAds.com

My book Barcodes with iOS is nearing completion. Buy it now to get early access!
Our DNA is written in Objective-C
Jump

DTXMLRPC for Posting to WordPress

On Fridays I like to do something fresh. Today I wrote an XML-RPC framework. The reason for doing that is that I love Amy Worrall’s QuickRadar.

Since I am trying my best to file good bug reports I spend much time on them. Being economically minded I like to reuse the same content I produce as much as possible. So when I file a Radar with QuickRadar I post to Apple’s bug report, to OpenRadar, share the link on App.net and on Twitter. What was missing in my opinion was to also get the text of the bug report into a new WordPress blog post.

The fruits of my labor you can admire on my Open Source DTXMLRPC framework which works on iOS and Mac. The DTXMLRPC project is on GitHub. Bear in mind that this is only a single day of work, nevertheless I did my best to comment the headers. Some uses cases might not be fully implemented, for example some variable types, like base64. I have the code for that already in DTFoundation, so if somebody needs it I can quickly add this.

The WordPress API is XML-RPC throughout, so this is the reason why I called the framework after the underlying XML-RPC technology. DTWordpress implements a few basic operations I needed.

To post a new blog post all you need to do is this:

DTWordpress *wordpress = [[DTWordpress alloc] initWithEndpointURL:endpointURL];
wordpress.userName = userName;
wordpress.password = password;
 
NSDictionary *content = @{@"title":title, @"description":description, @"post_type":@"post"};
 
[wordpress newPostWithContent:content shouldPublish:NO completion:^(NSInteger postID, NSError *error) {
   // returns the new post ID or an error
}];

Now today’s project would only be half complete if I wouldn’t have tried to see if I couldn’t add this to QuickRadar as well.

I forked it and thanks to a clear and modular API design I was able to add a QRWordpressSubmissionService in under an hour. QuickRadar is obviously built to be easily extendable. I went for the minimum feasible integration for starters.

QuickRadar WordPress Config

 

I won’t bore you with the details of the integration. Suffice it to say that those QRSubmissionService sub-classes have a very nice mechanism of working together, being managed by a QRSubmissionController. You can even add hard and soft dependencies. Like I don’t want to post anything if the filing of the Radar itself fails.

Of course you con always make stuff nicer, but I am a firm believer that the first version should be functional first and pretty second. Also I had seen that there seems to be some UI reworking coming and I don’t want to waste time on UI that will probably change anyway.

As soon as those UI updates are in, we can make sort of a WordPress setup wizard where you only have to enter the blog URL and the rest will be auto-detected. Also adding categories and tags is an option for the future. Other blog engines are also an option since most of them share some degree of the same APIs as WordPress.

Conclusion

I hope that Amy (and the other users using QuickRadar) take a liking to my work that I submitted a pull request for inclusion in origin master.

If you have some app or project that might benefit from DTXMLRPC or DTWordpress please get in touch, I’d be happy to collaborate on this.


Categories: Projects

%d bloggers like this: