【发布时间】:2010-08-10 12:00:00
【问题描述】:
我正在使用 xmlrpc 成功使用以下代码在 java 中发布到 wordpress
// 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();
}
除类别外,一切正常。我已经看到它们需要在数组中传递,但我没有像这样成功传递它们:
hmContent.put("categories", "[Cat1,Cat2]");
谁能帮我弄清楚为什么这些类别没有显示出来?
【问题讨论】: