views:

26

answers:

1

I am posting to wordpress in java using xmlrpc successfully using the following code

    // Hard-coded blog_ID
int blog_ID = 1;

// XML-RPC method
String xmlRpcMethod = "metaWeblog.newPost";

// Create our content struct
...

// You can specify whether or not you want the blog published
// immediately
boolean publish = true;

try {
    XmlRpcClient client = new XmlRpcClient(twtr2wp.xmlRpcUrl, false);

    Object token = client.invoke(xmlRpcMethod, new Object[] {
            new Integer(blog_ID), 
            twtr2wp.wpUsername, 
            twtr2wp.wpPassword,
            hmContent, 
            new Boolean(publish) });

    // The return is a String containing the postID
    System.out.println("Posted : " + token.toString());
} catch (Exception e) {
    e.printStackTrace();
}

Everything is working except for categories. I have seen that they need to be passed in an array but I have not been successful passing them like this:

hmContent.put("categories", "[Cat1,Cat2]");

Can anyone help me figure out why the categories are not showing up?

A: 

Just a guess in the dark here, have you tried to put String array instead of [Cat1, Cat2] into the hmContent ?

Something like this hmContent.put("categories", new String[]{"Cat1", "Cat2"});

wongiseng
Thanks, not sure why that escaped me.
patriot21