我正在尝试使用此代码在wordpress中发布数据,但我得到令牌null
代替sXmlRpcURL我也使用了http://wordpress.com/和http://sUsername.wordpress.com/,但两种情况下它都生成了令牌。
String sXmlRpcURL= arg[0];
String sUsername = arg[1];
String sPassword = arg[2];
// Hard-coded blog_ID
int blog_ID = 1;
// XML-RPC method
String sXmlRpcMethod = "blogger.newPost";
// XML-RPC method ver 2
// sXmlRpcMethod =“metaWeblog.newPost”; //我也用过这个
// We'll hard-code our blog content for now as well
String sTitle = "HI........";
String sContent = "Hello XML-RPC World!";
// Create our content struct
HashMap hmContent = new HashMap();
hmContent.put("title", sTitle);
hmContent.put("description", sContent);
// You can specify whether or not you want the blog published immediately
boolean bPublish = true;
// Try block
try {
// Create the XML-RPC client
XmlRpcClient client = new XmlRpcClient(sXmlRpcURL,true);
// Make our method call
Object token = client.invoke( sXmlRpcMethod, new Object[] { new Integer( blog_ID ), sUsername, sPassword, hmContent, new Boolean( bPublish ) } );
// The return is a String containing the postID
System.out.println("Posted : " + (String) token);
} // Catch exceptions
catch (Exception e) {
}
请帮帮我。
答案 0 :(得分:1)