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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<?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); ?> |