简体   繁体   中英

How do I create with Java a well formatted request to publish on Wordpress with XML-RPC?

I've found this guide on internet to publish on Wordpress using XML-RPC inside my Java Project, for example I want a message on my Blog, every time it's specified date. http://wordpress.rintcius.nl/post/look-how-this-wordpress-post-got-created-from-java

Now, I've followed the guide and I'm trying to let it run but I don't understand yet how exactly parameters for my post works. For example using the method blogger.NewPost I call:

public Integer post(String contents) throws XmlRpcException {
    Object[] params = new Object[] {
        blogInfo.getApiKey(),
        blogInfo.getBlogId(),
        blogInfo.getUserName(),
        blogInfo.getPassword(),
        contents,
        postType.booleanValue()
    };
    return (Integer) client.execute(POST_METHOD_NAME, params);
    }

and my "contents" value is:

[title]Look how this wordpress post got created from java![/title]"
        + "[category]6[/category]"
        + FileUtils.getContentsOfResource("rintcius/blog/post.txt");

(I'm using "[" instead of "<" and "]" instead of ">" that are processed by stackoverflow)

Now, how could I use all parameters in this XML way? Parameters here: http://codex.wordpress.org/XML-RPC_MetaWeblog_API#metaWeblog.newPost

And, it's the content only a "string" without any tag?

Thanks a lot to all!

Still don't know why it gives me back errors but i think it's only a bit outdated. Found this other libraries that works perfectly http://code.google.com/p/wordpress-java/

I advice all to use this since the other one is outdated Thanks all

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM