Is there a way i can create and publish a blogpost in my wordpressblog out of my app? I need examples/tutorials. I ve read about the API but didn't get the clue how to implement this in my android app. Does this work only on wordpress.com hosted sites or can i use my own?
I have pasted some code from https://code.google.com/p/wordpress-java/source/browse/src/net/bican/wordpress/example/Main.java
import java.net.MalformedURLException;
import java.util.List;
import redstone.xmlrpc.XmlRpcFault;
import net.bican.wordpress.Page;
import net.bican.wordpress.PageDefinition;
import net.bican.wordpress.Wordpress;
/**
*
* Example implementation
*
* Run this as java net.bican.wordpress.example.Main <username>
* <password> <xmlrpc-url> for your blog.
*
* @author Can Bican
*
*/
public class wordpressHelper {
/**
* @param args
* @throws MalformedURLException
* @throws XmlRpcFault
*/
@SuppressWarnings("nls")
public static void main(String[] args) throws MalformedURLException,
XmlRpcFault {
String username = args[0];
String password = args[1];
String xmlRpcUrl = args[2];
Wordpress wp = new Wordpress(username, password, xmlRpcUrl);
List<Page> recentPosts = wp.getRecentPosts(10);
System.out.println("Here are the ten recent posts:");
for (Page page : recentPosts) {
System.out.println(page.getPostid() + ":" + page.getTitle());
}
List<PageDefinition> pages = wp.getPageList();
System.out.println("Here are the pages:");
for (PageDefinition pageDefinition : pages) {
System.out.println(pageDefinition.getPage_title());
}
System.out.println("Posting a test (draft) page from a previous page...");
Page recentPost = wp.getRecentPosts(1).get(0);
recentPost.setTitle("Test Page");
recentPost.setDescription("Test description");
String result = wp.newPost(recentPost, false);
System.out.println("new post page id: " + result);
System.out.println("\nThat's all for now.");
}
}
I also put in the jwordpress-0.5.1.jar and added that in the classpath.
I get the swirling red line underneath redstone import redstone.xmlrpc.XmlRpcFault;
-> The import cannot be resolved...
2nd july 2013: I managed to get rid of the import problem... I downloadedhttp://sourceforge.net/projects/xmlrpc/files/%28New%29%20Redstone/1.1.1/ an extracted the zip file Then added all files in a new package into src. The import works right now but next Problem is that the javax.servlet cannot be resolved...