Categories

Getting a list of the recent posts

Using the metaWeblog.getRecentPosts API you can retrieve a list of the recent posts. In the following example a variable $limit will be expected in order to constrain the number or results.

<?php
include_once('wp-includes/class-IXR.php');
define('BLOG_ID', 0);
define('RPC_USERNAME', 'sanraul');
define('RPC_PASSWORD', '******');
 
$limit = $_REQUEST['limit'];
if(!isset($limit)){
	define('LIMIT', 10);
}else{
	define('LIMIT', $limit);
}
 
$client = new IXR_Client('http://localhost:8888/xmlrpc.php');
$client->query('metaWeblog.getRecentPosts', BLOG_ID, RPC_USERNAME, RPC_PASSWORD, LIMIT);
$posts = $client->getResponse();
 
echo json_encode($posts);
?>

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 12 + 15 ?
Please leave these two fields as-is: