Using Blog API's

Almost every standard compliant blogs support three blogging API which are “Blogger API” , “MovableType API” and “MetaWeblog API”. Among these three, MW (or MetaWeblog) is used more than other two. WordPress also supporst these three sets of API. If you are interesetd how to interact with these API’s – then take a look at the following example.

First lets discover which XMLRPC methods are suported by wordpress XMLRPC server. After digging a bit further we found that the following methods are supported

system.multicall
system.listMethods
system.getCapabilities
demo.addTwoNumbers
demo.sayHello
pingback.extensions.getPingbacks
pingback.ping
mt.publishPost
mt.getTrackbackPings
mt.supportedTextFilters
mt.supportedMethods
mt.setPostCategories
mt.getPostCategories
mt.getRecentPostTitles
mt.getCategoryList
metaWeblog.getUsersBlogs
metaWeblog.setTemplate
metaWeblog.getTemplate
metaWeblog.deletePost
metaWeblog.newMediaObject
metaWeblog.getCategories
metaWeblog.getRecentPosts
metaWeblog.getPost
metaWeblog.editPost
metaWeblog.newPost
blogger.deletePost
blogger.editPost
blogger.newPost
blogger.setTemplate
blogger.getTemplate
blogger.getRecentPosts
blogger.getPost
blogger.getUserInfo
blogger.getUsersBlogs

so to make a new post using metaWeblog.newPost method lets take a look at the following example.

<?php
	include("xmlrpc.inc.php");
	$c = new xmlrpc_client("/wp/xmlrpc.php", "localhost", 80);

	$content['title']="XMLRPC Post";
	$content['description']="Some content posted using MetaWeblog API";
	$content['categories'] = array("frontpage");
	$x = new xmlrpcmsg("metaWeblog.newPost",
	                    array(php_xmlrpc_encode("1"),
                        php_xmlrpc_encode("admin"),
                        php_xmlrpc_encode("root"),
                        php_xmlrpc_encode($content),
                        php_xmlrpc_encode("1")));

	$c->return_type = 'phpvals';
	$r =$c->send($x);
	if ($r->errno=="0")
	echo "Successfully Posted";
	else {
		echo "There are some error";
		print_r($r);
              }
?>

Thats it!!