Using AtomPub to Export from Wordpress
Ever since someone gave me an overview of RESTful web development in the same week that someone else gave me an overview of the Atompub protocol, I've been hooked on the idea.
I've tinkered around with starting implementations of both a client and a server on my own ever since. Part of that activity was because there weren't very many tools that supported Atompub. That actually makes doing that kind of development a pain.
That's because you're trying to do both ends of a client-server implementation without having either side ready to work. It's always much easier to work on one end of such a system when the other end is already in place.
While there have been tools for testing Atompub servers, some early servers, etc. out there, but most required quit a bit of yak shaving before you could work on the other side.
Fortunately, that's starting to change. While I still am pursuing my own implementations, I now have adequate implementations to work with on both sides: Windows Live Writer on the client side and Wordpress on the server.
One of the things I'm aiming for in working with this whole chain of tools is a central repository of content that I create: notes, bookmarks, articles, documents, images, etc. all in one place. From there, the content can be pushed out to the various sites I want it on.
Anyway, one of the things that I wanted to do as part of this was to get a copy of all of the content from this site as individual Atom documents. This would give me a large test set of posts that reflect my own real usage.
So, I wrote a bare minimum export to get all ~900 posts. One of the secondary reasons I wanted to use this is that this site's installation of Wordpress is chronically messed up.
Accordingly, a real implementation should actually query the service for the list of posts instead of just looping through the list. For whatever reason, this site's setup, that didn't work, hence the for(i) loop. But, that means some 404 errors in the middle from deleted posts.
Regardless, in just a few lines of C# code, I had a nice directory containing all of my posts. The code follows.


