Categories

Retrieving an individual post using XML-RPC

You can get the information of a single post by calling the metaWeblog.getPost method. You will have to pass the $post_id, $user_name, and $user_password.

<?php
include_once('wp-includes/class-IXR.php');
define('BLOG_ID', 0);
define('RPC_USERNAME', 'sanraul');
define('RPC_PASSWORD', '*****');
 
$id = $_REQUEST['id'];
if(!isset($id)){
	echo '{"faultCode":000,"faultString":"Missing \'id\' parameter."}';
	exit;
}
 
$client = new IXR_Client('http://localhost:8888/xmlrpc.php');
$client->query('metaWeblog.getPost', $id, RPC_USERNAME, RPC_PASSWORD);
$post = $client->getResponse();
 
echo json_encode($post);
?>

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

IMPORTANT! To be able to proceed, you need to solve the following simple math (so I know that you are a human) :-)

What is 3 + 13 ?
Please leave these two fields as-is: