So my favorite side hobby is writing programs for my MAC. And today I
wanted to use the spaces public api’s to publish blog entries from my
MAC.

This means that I would use Cocoa, XCode, and then The Web Services Toolkit

Starting off I found a lot of cool resources that would help me out

Spaces API set

Metaweblog API
set
Example code of a XML-RPC call with Cocoa (only had one param though)
Example code of using the Web Services Toolkit
And of course some references from Dareo too in his blog.

Using the Spaces API set means that you are actually implementing the
calls to the Metawebblog API set. All of their APIs except one which
spaces does not support.

I decided to just call the blogger.getUserInfo API since it seemed simplest. The Spaces doc says that you just have to call into the URL of http://storage.msn.com/storageservice/MetaWeblog.rpc with the method name and the params of the space name, secret word, and password.

Next I looked at a sample set of code from ranchero.com and used it as  skeleton.

The I started digging into the WebServicesToolkit

The way it works is that you create a request that contains an NSDictionary Object.  There are a couple of ways you can populate a dictionary object either dynamically or statically.  I did it statically.  After populating it you submit it.  You do have the option of specifying the order of the param submission if you have more than one param, but figuring out how to specify order is really hard.  So I just left it with the default order.

Then after submission I got Nada.  just an access denied. I thought hey, is the API down.  So I downloaded some other programs that were listed on Dare’s site and tried them out.  Some people said that they too returned access denied but it worked for me.  So what was I doing wrong.

I figured I needed to see the raw XML of the request, so I said I would have to deserilize the request object which would be the opposite of WSMethodInvocationCopyParameters.  But there was no such function. 

Then I said lets just sniff the wire.  So off to find tcp dump and ethereal for the mac.  Found both of them did in install of ethereal from fink and compiled tcp dump.  I hear so many people talk about tcp dump so I tried that first.  I figured out my wireless was en1 not eth1 like on linux.  and figured out -w was to write to a logfile and -vvv and -XX were options for the detailed output.  Then to read the output file I had to use ethereal.  (I tried to use ethereal first since it has  a GUI, but finding out which NIC is which there is all based on IPV6 notation and I have listed 4 NICS, bluetooth, loopback, ethernet and wireless so go figure)
Ethereal said that the HTML which was recorded was short or cut off, so I must have missed some param.  I tried to figure it out in the man pages for tcp dump, but nada…. 
So I figured I better just get ethereal working.  So I tried each and every NIC but first you have to turn off/on the nic before connecting.  Then I found en1 and recorded the traffic.
And here is the problem, if you do not specifiy the order then you will end up with a reverse order from the NSDictionary object than you submitted, which results in the submission of a space you do not own with a blank password. 

So not to first just reverse the entry into the NSDictionary and then off to get the order thing figured out.

Of course if I could get MONO working on my Intel MAC with MONODevelop then I could just use the MSDN sample code which worked in VC# Express within Parallels. 

Ok back to coding 🙂

This entry was posted in Computers and Internet. Bookmark the permalink.