开发者

Post data in wordpress from java using xmlrpc

开发者 https://www.devze.com 2023-03-03 07:49 出处:网络
I am trying to po开发者_JAVA技巧st data in wordpress using this code but I am getting token null

I am trying to po开发者_JAVA技巧st data in wordpress using this code but I am getting token null

In place of sXmlRpcURL I have used http://wordpress.com/ and http://sUsername.wordpress.com/ also but both the cases its generating token null.

    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"; // I have used this also

    // 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) {
    }

please help me.


I have got the solution you want to use -

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

for sXmlRpcURL. Now it working well-

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号