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!
Configuration
|
configuration key |
description |
|
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:
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 CommentIf 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 1Comment 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 backcomment.load();System.out.println(comment.getCommentId());[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 backAOMComment *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);}];Blog.loadList { (models, error) in if error == nil { guard let allMyBlogs = models as? [Blog] else { return } for let blog in allMyBlogs { print(blog.blogId.description) } } }// 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 backvar comment = Comment()comment.author = "John Doe"comment.content = "These are my two cents!"comment.postId = 42comment.blogId = 1comment.save { (error) in}//Check if we got an ID backcomment.load { (error) in print(comment.commentId.description)}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 1var 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:
MediaItem image = new MediaItem();image.setTitle("logo.png" ); //this is the filenameimage.setType("image/png" ); //the mime typeimage.setData( getImage( ) ); //getImage() geturns a base64 encoded string version of your image fileimage.save( );Integer attachmentId = image.getAttachmentId();//use the attachment id for your post to get the image attached to it:...myPost.setAttachmentId(attachmentId);...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]; ...}];let image = MediaItem()image.title = "logo.png" //this is the filenameimage.type = "image/png" //the mime typeimage.mediaData = String(data: imageData, encoding: .utf8) as? Stringimage.save { (error) in let attachmentId = image.attachmentId //use the attachment id for your post to get the image attached to it: ... myPost.attachmentId = attachmentId ...}var image = new Apiomat.MediaItem();image.setTitle("logo.png" ); //this is the filenameimage.setType("image/png" ); //the mime typeimage.setData( getImage( ) ); //getImage() geturns a base64 encoded string version of your image filevar 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);