Skip to content

Instantly share code, notes, and snippets.

@jhaus
Created December 4, 2010 23:43
Show Gist options
  • Save jhaus/728608 to your computer and use it in GitHub Desktop.
Save jhaus/728608 to your computer and use it in GitHub Desktop.
get-recent-posts via: http://bit.ly/gyHw5K
<?php
set_time_limit(0);
require_once("IXR_Library.php.inc");
$client->debug = true; // Set it to fase in Production Environment
// Create the client object
$client = new IXR_Client('Your Blog URL/xmlrpc.php');
$username = "Blog Admin/Editor/Author User Name";
$password = "PASSWORD";
$params = array(0,$username,$password,10); // Last Parameter tells how many posts to fetch
// Run a query To Read Posts From Wordpress
if (!$client->query('metaWeblog.getRecentPosts', $params)) {
die('Something went wrong - '.$client->getErrorCode().' : '.$client->getErrorMessage());
}
$myresponse = $client->getResponse();
$i=0; ?>
<table border="1" cellpadding="0" cellspacing="2">
<tr>
<td>Sr. No</td>
<td>Date</td>
<td>Author</td>
<td>Post Id</td>
<td>Title</td>
<td>Categories</td>
<td>Tags</td>
<td>Status</td>
</tr>
<?php //foreach ($myresponse as $key => $value)
foreach ($myresponse as $res)
{
if($res['post_status']!="draft"){
//$times = new IXR_Date(); ?>
<tr>
<td><?php echo $i+1; ?></td>
<td>
<?php
$object = $res['dateCreated'];
echo $object->day."-".$object->month."-".$object->year." ".$object->hour.":".$object->minute; ?></td>
<td><?php echo $res['wp_author_display_name']; ?></td>
<td><?php echo $res['postid']; ?></td>
<td><a href="<?php echo $res['permaLink']; ?>"><?php echo $res['title']; ?></a></td>
<td>
<?php echo implode($res['categories'],", ") ?>
</td>
<td><?php echo $res['mt_keywords']; ?></td>
<td><?php echo $res['post_status']; ?></td>
</tr>
<?php $i++; } } ?>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment