In our first part we just discussed what is a blogging API and how we can utilize them. In this post I am going to show how to fetch available categories in a blog and how to retrieve a specific post.
To retrieve available categories you have to use metaWeblog.getCategories as shown below
<?php include("xmlrpc.inc.php"); $c = new xmlrpc_client("/xmlrpc.php", "hasin.wordpress.com", 80); $c->return_type = 'phpvals'; // let client give us back php values instead of xmlrpcvals echo "<pre>"; $x = new xmlrpcmsg("metaWeblog.getCategories",array(php_xmlrpc_encode("1"), php_xmlrpc_encode("someusername"), php_xmlrpc_encode("somepassword"))); $r =$c->send($x); if ($r->errno=="0") print_r($r); ?>
And To retrieve a specific post you have to metaWeblog.getPost API as shown here
<?php include("xmlrpc.inc.php"); $c = new xmlrpc_client("/xmlrpc.php", "hasin.wordpress.com", 80); $c->return_type = 'phpvals'; // let client give us back php values instead of xmlrpcvals echo "<pre>"; $x = new xmlrpcmsg("metaWeblog.getPost",array(php_xmlrpc_encode("1"), //postId php_xmlrpc_encode("someusername"), php_xmlrpc_encode("somepassword"))); $r =$c->send($x); if ($r->errno=="0") print_r($r); ?>