3

我正在尝试使用此代码在 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) {
    }

请帮我。

4

1 回答 1

1

我有你想要使用的解决方案 -

http://sUsername.wordpress.com/xmlrpc.php

对于 sXmlRpcURL。现在它运行良好-

于 2011-05-06T08:28:33.710 回答