debug = true; echo('
');

// ####################### Let's create a new Post ####################### //

// Set Post data
$post = array ('Post' => 
  array (
    'title' => 'My First XML-RPC Post',
    'body' => 'This is the post body.',
  ),
);

// Call post.add
if (!$client->query('post.add', $post)) {
    die('Something went wrong - ' . $client->getErrorCode() . ' : ' . $client->getErrorMessage());
}

// Get new Post ID
$post_id = (int)$client->getResponse();

echo("New Post ID: {$post_id}\r\n");

// ####################### Let's display the new Post ####################### //

// Call post.view
if (!$client->query('post.view', $post_id)) {
    die('Something went wrong - ' . $client->getErrorCode() . ' : ' . $client->getErrorMessage());
}

// Get the Post data
$data = $client->getResponse();

// Display the Post data
print('Post data: ');
print_r($data);

// ####################### Let's edit the Post ####################### //

// Change Post data
$data['Post']['title']    = 'My First Edited XML-RPC Post';
$data['Post']['modified'] =  date('Y-m-d H:i:s');

// Call post.edit
if (!$client->query('post.edit', $data)) {
    die('Something went wrong - ' . $client->getErrorCode() . ' : ' . $client->getErrorMessage());
}

echo("Post Modified\r\n");

// ####################### Let's delete the Post ####################### //

// Call post.delete
if (!$client->query('post.delete', $data['Post']['id'])) {
    die('Something went wrong - ' . $client->getErrorCode() . ' : ' . $client->getErrorMessage());
}

echo("Post Deleted\r\n");

echo('
'); ?>