. . .

WordPress Module

Using the WordPress module you can create, delete, update and read blog posts of your WordPress blog. Please pay attention that you enable the RPC interface first!

images/download/attachments/10718931/db3-module-wordpress.PNG

Configuration

User name

The RPC user name of your blog

User password

The RPC user password

XML RPC URL

The RPC URL of your blog. Normally the URL looks like this: http://yourdomain.com/xmlrpc.php

For more information also look at WordPress Documentation

Usage


Beginning with WordPress 3.4, there are some old new data models marked as obsolete:

  • Categories – use Taxonomies instead, with taxonomy=’category’

  • Tags – use Taxonomies instead, with taxonomy=’post_tag’

  • Pages – use Posts instead, with post_type=’page’

After setting the configuration parameters and deploying your app, every 30 minutes your blog is queried for new posts. The new data objects are stored and may be loaded using the data models from the SDK like this:

Android
Blog blog = new Blog();
List<blog> allMyBlogs = blog.get("");
for(Blog blog : allMyBlogs) {
System.out.println(blog.getBlogId());
}
// Same works for Post, Author, Term, and Comment
If you create a new object and save it, this one is also create on your blog synchronously:
 
// Lets create a new comment to an existing page with ID 42 on blog with ID 1
Comment comment = new Comment();
comment.setAuthor("John Doe");
comment.setContent("These are my two cents!");
comment.setPostId(42);
comment.setBlogId(1);
comment.save();
 
//Check if we got an ID back
comment.load();
System.out.println(comment.getCommentId());
iOS
[AOMBlog getAsyncWithQuery:@"" withBlock:^(NSMutableArray *allMyBlogs, NSError *error) {
if(error == FALSE)
{
for (AOMBlog *blog in allMyBlogs) {
NsLog(@"%@", [blog blogId]);
}
}
}];
// Same works for Post, Author, Term, and Comment
// If you create a new object and save it,
// this one is also create on your blog synchronously:
 
// Lets create a new comment to an existing page with ID 42 on blog with ID 1
//Check if we got an ID back
AOMComment *comment = [[AOMComment alloc] init];
[comment setAuthor:@"John Doe"];
[comment setContent:@"These are my two cents!"];
[comment setPostId:42];
[comment setBlogId:1];
[comment saveAsyncWithBlock:^(NSError *error) {
 
}];
 
//Check if we got an ID back
[comment loadAsyncWithBlock:^(NSError *error) {
NSLog(@"%@", comment commentId);
}];
JavaScript
var blog = new Apiomat.Blog()
var allMyBlogs=blog.get("");
for (index = 0; index < allMyBlogs.length; ++index) {
console.log(allMyBlogs[index].getBlogId());
}
 
// Same works for Post, Author, Term, and Comment
//If you create a new object and save it, this one is also create on your blog synchronously:
 
// Lets create a new comment to an existing page with ID 42 on blog with ID 1
var comment = new Apiomat.Comment();
comment.setAuthor("John Doe");
comment.setContent("These are my two cents!");
comment.setPostId(42);
comment.setBlogId(1);
 
var loadCB = {
onOk : function() {
console.log(comment.getCommentId());
},
onError : function(error) {
console.log("Some error occured: (" + error.statusCode + ")" + error.message);
}
};
 
var saveCB = {
onOk : function() {
console.log("saved");
 
//Check if we got an ID back
comment.load(loadCB);
},
onError : function(error) {
console.log("Some error occured: (" + error.statusCode + ")" + error.message);
}
};
 
comment.save(saveCB);

If you have loaded or created a new object, you can also update and delete the objects using the given methods in your SDK.
You can also upload new media files like follows:

Android
MediaItem image = new MediaItem();
image.setTitle("logo.png" ); //this is the filename
image.setType("image/png" ); //the mime type
image.setData( getImage( ) ); //getImage() geturns a base64 encoded string version of your image file
image.save( );
 
Integer attachmentId = image.getAttachmentId();
//use the attachment id for your post to get the image attached to it:
...
myPost.setAttachmentId(attachmentId);
...
iOS
AOMMediaItem *image = [[AOMMediaItem alloc] init];
[image setTitle:@"logo.png" ] ; //this is the filename
[image.setType:@"image/png" ]; //the mime type
[image setData: getImage( ) ]; //getImage() geturns a base64 encoded string version of your image file
[image saveAsyncWithBlock:^(NSError *error) {
NSInteger attachmentId = [image attachmentId];
//use the attachment id for your post to get the image attached to it:
...
[myPost setAttachmentId:attachmentId];
...
}];
JavaScript
var image = new Apiomat.MediaItem();
image.setTitle("logo.png" ); //this is the filename
image.setType("image/png" ); //the mime type
image.setData( getImage( ) ); //getImage() geturns a base64 encoded string version of your image file
 
var saveCB = {
onOk : function() {
Integer attachmentId = image.getAttachmentId();
//use the attachment id for your post to get the image attached to it:
//...
myPost.setAttachmentId(attachmentId);
//...
},
onError : function(error) {
console.log("Some error occured: (" + error.statusCode + ")" + error.message);
}
};
image.save(saveCB);
* link only available in Enterprise Documentation