See the Snippets! You can get productive in minutes or waste days and debug huge amounts of free and crappy code to get to 5% of elWpAPI's functionality.

WordPress Remote Control

WordPress XMLRPC Remote Publishing API (and beyond) by Easy-to-use PHP Objects

••• Hey there! Click here to buy, download or update the WpAPI library ONLY after you read the #3 Testimonials •••

Foreplay

These are real life usage examples. But the Snippets pages cover things a lot more and in-depth.

Amateur Usage Example

<?php
// Require elWpAPI presence
require_once(dirname(__FILE__).'/WpAPI.php');
// Enter your blog domain[/path] (path is optional)
$xmlrpc = 'http://.../xmlrpc.php';
// And your admin account and password here
list($username, $password) = array('admin', '...');
// Prepare the elWpAPI object
$wpapi = new elWpAPI($xmlrpc, $username, $password);
$post_ID = null; // Init upfront postID to 0
// Test credentials and proceed only on success

if($valid_login = $wpapi->validateLogin()){
     
// Get the blog title and description.
     $blog_title = $wpapi->getBlogTitle();
     
$blog_description = $wpapi->getBlogTagline();
     
// Now attempt to post and act accordingly based on result
     $post_ID = $wpapi->createPost(
          
'Title', 'Text', 'More Text (Optional)', 'Excerpt',
          
'post-slug', // The slug of the new post
          0, // Let time be setup by WordPress
          'publish', // Publish or Draft
          // Categories (, OR CRLF separated string also accepted)
          array('Category1', 'Category2',),
          
// Tags (, OR CRLF separated string also accepted)
          array('Tag1', 'Tag2',),
          
// Array of custom fields
          array('cf1' => 'Value1', 'cf2' => 'Value2',)
     
);
}
// Here we query the Error log for a report of last call
// (Error info is returned regardless of success state)

$error = $wpapi->getLastError(); // Minimal error info
$error_ex = $wpapi->getLastErrorEx(); // Detailed error info
if(!$valid_login){
     
// Credentials are wrong, handle as you wish
}else{
     
if(is_numeric($post_ID) and (($post_ID = intval($post_ID)) > 0)){
          
// We get here only if posting succeeds, handle as you wish
     }else{
          
// Failed to post, handle as you wish also
     }
}
?>

Professional Usage Example

<?php
// Require elWpAPIwrap presence (it pulls elWpAPI in by itself)
require_once(dirname(__FILE__).'/WpAPIwrap.php');
// Enter your blog domain[/path] (path is optional)
$xmlrpc = 'http://.../xmlrpc.php';
// And your admin account and password here
list($username, $password) = array('admin', '...');
// Prepare the elWpAPI object
$wpapi = new elWpAPI($xmlrpc, $username, $password);
// elWpAPIwrap is created by using an elWpAPI as constructor argument
$wpwrap = new elWpAPIwrap($wpapi);
// This is how easy it is to create a post with native WP API
// It's the same as using wp_insert_post() when writing Plugins

$postID = $wpwrap->Wp_Insert_Post(array(
     
'post_title' => 'Title1',
     
'post_content' => 'Text1',
     
'post_status' => 'publish',
));
// Success lies within numbers
if(is_numeric($postID)){
     
// Add post custom field
     $wpwrap->Update_Post_Meta($postID, 'metaname', 'metavalue');
     
// And this is how you delete it (permanently, no trash)
     $wpwrap->Wp_Delete_Post($postID, true);
}
?>