Monday, August 21, 2006

Blogger API

I grew tired of using the Blogger web interface, so I wrote an offline editor. I've spent yesterday evening and an hour or two today on it. I didn't like any of the existing editors I've tried - I don't need WYSIWYG, I just need the raw HTML. I can put classes etc. on the HTML as required, and style them later.

Primary thing I wanted was a nice editor to edit with. That's why I'm using the code editor from SharpDevelop (ICSharpCode) - the minimum I wanted was auto-indent, but it has quite a bit more than that (even if it does have some minor bugs).

My offline editor is simply a cache of notes, waiting to be sent. No configuration needed, really - autosave when you're editing and closing, autoload on startup.

This may mean that I post somewhat more often than I did, but in shorter snippets. It should reduce the barrier to posting.

Update: Now I've got to find a way to avoid Blogger escaping my HTML :) As I read the docs, the Atom payload type '<content type="html"> is supposed to take escaped HTML. That's what I'm sending - XML-escaped HTML - but it looks like it's being treated by Blogger as 'xhtml' or similar, and dumped out verbatim.

Ref: Meaning of type attribute

Maybe it's a namespace issue. More experimentation required.

Strange. I had an Atom namespace in the root. I commented it out and posted again, but got a null pointer Java exception on the Google / Blogger server side, so I put it back - and now it just works! If you're missing the namespace, this is what you get from Blogger:

java.lang.NullPointerException
 at com.google.blogger.xapi.EntryToPostTranslator.translate(EntryToPostTranslator.java:80)
 at com.google.blogger.xapi.PostFeedProvider.bloggerInsert(PostFeedProvider.java:176)
 at com.google.blogger.xapi.BlogFeedProvider$2.call(BlogFeedProvider.java:214)
 at com.google.blogger.xapi.BlogFeedProvider$2.call(BlogFeedProvider.java:213)
 at com.google.blogger.xapi.BlogFeedProvider.serviceRequest(BlogFeedProvider.java:254)
 at com.google.blogger.xapi.BlogFeedProvider.insert(BlogFeedProvider.java:212)
 at com.google.gdata.provider.IntrospectableProvider.insert(IntrospectableProvider.java:95)
 at com.google.gdata.servlet.GDataServlet.processInsertOperation(GDataServlet.java:468)
 at com.google.gdata.servlet.GDataServlet.doPost(GDataServlet.java:387)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
I wrote my little client in C#, but I didn't use the Blogger C# library currently on Google Code - it has Java-itis, factories and interfaces everywhere without clear purpose.

No comments: