English 中文(简体)
Tagging Posts via Wordpress XMLRPC
原标题:

i am trying to publish a new post to a wordpress blog over the XMLRPC API. This works out fine so far, but now i want to add tags to the post. Either at creation time or afterwards. But i can t find any solutions in the supported APIs.

Any clue on how i can tag new posts via XMLRPC requests?

最佳回答

Edit mt_keywords property.

问题回答

I hope this code helps

import redstone.xmlrpc.XmlRpcClient;

import java.util.HashMap;

public class wp {


public static void main(String args[]){

    System.out.println("Inciando processo de publicação...");


      // Get command-line arguments into variables
      String sXmlRpcURL = "http://localhost/wordpress/xmlrpc.php";
      String sUsername = "admin";
      String sPassword = "mds123";

      // Hard-coded blog_ID
      int blog_ID = 1;

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

      // We ll hard-code our blog content for now as well
      String sContent = "Hello XML-RPC World! 5";
      String sTitle = "Hello XML-RPC Title 5";

      // Create our content struct
      HashMap hmContent = new HashMap();
      hmContent.put("title", sTitle);
      hmContent.put("description", sContent);
              hmContent.put("mt_keywords", "tag 1, tag 2");


      // 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, false );


        // 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 : " + token.toString() );
      }

      // Catch exceptions
      catch( Exception e )
      {
        e.printStackTrace( System.err );
      }


    System.out.println("Fim do processo de publicação...");

}




}




相关问题
C# Networking API s [closed]

Lately I ve been looking for a good networking API i could possibly use and/or reference some of the code within, but i have mere luck searching for some on Google/Bing. Hopefully somebody here has ...

getting XML from other domain using ASP.NET

I m fairly new to ASP.NET. And I was wondering how I could go about getting xml from a site (Kuler s API in this case), and then post the result using AJAX? So what I want here, is to be able to do a ...

Most appropriate API for URL shortening service

I ve just finished an online service for shortening URLs (in php5 with Zend Framework); you can enter an URL and you get an short URL (like tinyurl and such sites). I m thinking about the API for ...

UML Diagram to Model API

I need to create a diagram to document a RESTFul API that build, which UML diagram should I use? Thanks in advance,

How best to expose Rails methods via an API?

Let s say I have a model foo, and my model has a publish! method that changes a few properties on that model and potentially a few others too. Now, the Rails way suggests that I expose my model over ...

简讯

我是否可以使用某些软件来建立简便的航天国家服务器,最好是在 Java? 所有我都希望我的航天国家服务机在任何要求中都用同样的IP地址来回答。

About paypal express checkout api

In this picture,there are 3 main steps:SetExpressCheckout,GetExpressCheckoutDetails and DoExpressCheckoutDetails,I m now sure SetExpressCheckout is to be called by myself,what about ...

热门标签