September 30, 2003
mt.setPostCategories
I was having some problems the other day using mt.setPostCategories to set the category on my first test post using the XML-RPC API that MovableType provides. I found some info over at d2r, the code for mt.setPostCategories is just wrong - not even valid xml - and that ID in <name>categoryID</name> should be Id (arg!). So, I decided to learn more about XML-RPC and dug out some books and poked and proded until setting my category occurred without fault.
I still think that adding the primary category as part of the metaWeblog.newPost struct would be cool. It’s kinda crazy to post, set categories, republish. I’ve got a post in over at the MT forums asking this.
So now my little VB app works - just sends the XML-RPC raw - now to get into more of the XML document creation. (Why am I doing this? Just cuz I think XML is cool and have being playing around with the MSXML control a lot.)
Here’s the proper XML-RPC code for mt.setPostCategories: (I replaced tabs with spaces to make it look a little nicer on the web.)
<?xml version="1.0"?> <methodCall> <!-- The name of the method to call. --> <methodName>mt.setPostCategories</methodName> <params> <param> <value> <!-- Entry ID. --> <string>[MT ID of Entry]</string> </value> </param> <param> <value> <!-- The username to post this entry under. --> <string>[username]</string> </value> </param> <param> <value> <!-- The password for the username supplied above. --> <string>[password]</string> </value> </param> <param> <value> <array> <data> <struct> <member> <name>categoryId</name> <value> <string>[MT ID of category]</string> </value> </member> <member> <name>isPrimary</name> <value> <boolean>true</boolean> </value> </member> </struct> </data> </array> </value> </param> </params> </methodCall>
