Skip to content

Instantly share code, notes, and snippets.

@ruslankonev
Created February 4, 2014 07:19
Show Gist options
  • Save ruslankonev/8799372 to your computer and use it in GitHub Desktop.
Save ruslankonev/8799372 to your computer and use it in GitHub Desktop.
<?php
include("../wp-includes/class-IXR.php");
$client = new IXR_Client('http://www.example.com/xmlrpc.php');
if (!$client->query('wp.getCategories','', 'admin',’password’)) {
die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
}
$response = $client->getResponse();
$content['title'] = 'Test Draft Entry using MetaWeblog API';
$content['categories'] = array($response[1]['categoryName']);
$content['description'] = '<p>Hello World!</p>';
if (!$client->query('metaWeblog.newPost','', 'admin',’password’, $content, false)) {
die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
}
echo $client->getResponse(); //with Wordpress, will report the ID of the new post
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment