Word 2007, Metaweblog API and newMediaObject

IT Chapters No Comments »

Blogging via web interfaces is never fun. Even with all the Ajax goodness that is around, nothing beats a UI like Windows Live Writer (WLW) or Word for putting your thoughts into text. The richness of the desktop applications and the ease you can place graphics, charts and all sorts of extended media make it the perfect solution for blogging.

While this sounds good in theory, in practice this has been a long time coming. WLW was the first Microsoft release to natively support blogging and Word 2007 will be the first version of Word to support blogging inside the application itself. This is all done via the Metaweblog API which allows us to do most, if not all of the workflow required to get our thoughts published. The API supports methods like getPost, deletePost and newPost to add/edit/delete your blog entries. The addition of a 4th important method, newMediaObject allows clients to save binary data, be it images, zip files to the web server easily. The method definition from the API shows a very simple interface.

metaWeblog.newMediaObject (string blogid, string username, string password, struct mediaobject) returns struct

The return struct is a simple struct that holds the URL to the new media object. The struct passed as the last parameter holds a name, a type and a Base64 array of bytes. Simple! So simple in fact it took me all of an hour to get it up, running and tested for the Subtext blogging engine. Subtext uses the XML-RPC.net library for its XML RPC support and it is perfect for most if not all .NET XML RPC needs. At our office we decided that to implement the API to get blog posts from more employees. Everything went perfectly until we tried to get newMediaObject supported. WLW worked perfectly, saving images like there was no tomorrow. But Word 2007 failed at the first hurdle. Word 2007, being a user oriented application is not very verbose on reporting errors, and would simply return that our site did not support posting images directly. Hmmmm, time for some digging.

After much searching on Google, I came across this post, which pretty much points to a bug in Word itself. As you can see in the method declaration above, blogid is declared as an object of type string. However, Word in all its wisdom is trying to pass the blogid parameter as an integer. This in turn causes the XML RPC library to throw an exception. Wonderful. We attempted to change our API implementation to have blogid as just a plain object; so the method declaration would like this:

metaWeblog.newMediaObject (object blogid, string username, string password, struct mediaobject) returns struct

However, this just caused Word to think we hadn’t implemented the API method and would fail again. After a short deliberation, we’ve written another interface implementation for this method where blogid is an integer specifically for Word. Which is a bit of a bummer, as we would want a single implementation and API endpoint for all our clients but are held up by this bug. With Tim’s permission, I’ll be posting the code that we wrote today to support Word 2007 which has a very tight interface and class design and has cut the code necessary to support this down to nicely I’ll post an update once I get it all sorted.

Either way, this does fall to a Word issue. Not sure how this fell through Q&A, but the API isn’t being followed to the spec, which causes the issue to raise its head. Blogging with Word 2007 in itself is a glorious process. I’m using Word to write this post as we speak. Pasting in charts, images, graphs; full spell and grammar check and knowing you’re getting XHTML output in the end makes blogging a breeze. Keep it up Microsoft, this is definite step in the right direction, but let’s stay on the path already laid, OK? :)

A side-note: Some other blogging engines support this bug without any problems. For example, Wordpress works perfectly as it isn’t very strict on the variable types. Subtext and our custom software are strict on the types passed as .NET is a strongly typed framework by definition.

***UPDATE***
More info can be found on our company’s blog here:
http://www.dotnetsolutions.ltd.uk/blog/2007/01/04/livewritervsword2007andmetaweblogapi/

kick it on DotNetKicks.com

iTunes Losing Podcasts

Apple, General, Podcasting No Comments »

Apple, this is getting really old. iTunes is constantly losing podcasts. I plug my iPod in, and iTunes comes up and says “XXX was not copied to the iPod”. I check the podcast listings and the podcast has downloaded, but the file is missing (and iTunes doesn’t have a re-download option which to be honest is just plain stupid). Can I ever have this working properly on my PC? All I want is to plug in, sync and play. Last time I did an international flight, I knew I had about 20 podcasts lined up so I plugged the iPod in, left it for a few hours while packing, came back and unplugged and left for the airport. I sat in my seat, turned the iPod on and found…… most of the podcasts missing.

This is what iTunes is giving me on sync:

 
 

Post New Year

IT Chapters, Life in London, Photography, Zooomr No Comments »

Happy New Year everybody. 2006 was a “different” year for me, one that had loads of experiences, some I would want to do again (getting married) others not so much. I hope everyone has a great year; 2007 has great potential!

I’ve uploaded some new photos that I took the last couple of days to Zooomr, click on the photo below to see some more. I have a set from Dover coming, I just need to get round to process them.

Sometimes I feel pretty small