xml rpc – remote posting with incutio wordpress ixr class

In order to build a successful blog network I need xml-rpc. I read up on xml-rpc, incutio ixr and tried some basic flat file xml rpc. It’s either that or a custom php url to post data to and then use the wordpress functions to process it.

Xml-rpc is a lot easier especially with the WordPress Incutio-IXR class:

  1. include_once('wp-includes/class-IXR.php');
  3. //just give us your endpoint and we'll take it from there Sparky…
  4. $client = new IXR_Client('http://tryout.blacknorati.com/xmlrpc.php');
  6. // xml rpc post function form :
  7. // metaWeblog.newPost( blog_id, username, password, struct, publish )
  9. //struct = structure for post data
  10.  $post['title'] = 'test titel';
  11.  $post['description'] = 'test';
  12.  $post['categories'] = array("frontpage");
  14. //use 'query' to interact with the server, set publish to 0 (draft) for now
  15.  if (!$client->query('metaWeblog.newPost', 6, 'user', 'password', $post, 0)) {
  16.  die('Something went wrong – '.$client->getErrorCode().' : '.$client->getErrorMessage());
  17.  }
  18.         echo $client->getResponse();

Normally getResponse will return a PostID for this function.

Is it really that simple ? Yes. I skipped to the IXR_Client because my host does not have xmlrpc running and the IXR_class doesn’t use it, and solutions with email don’t easily allow access to tags and categories.

  1. $post['categories'] = array("frontpage");
  2. $post['mt_keywords']='key1, key2';
  3. $post["mt_allow_comments"] ='closed';
  4. $post['mt_allow_pings']='open';
  5. //$post['mt_tb_ping_urls'] ='url url url';
  6. //$post['enclosure']=array('url', 'length', 'type')';

mt_keywords holds my tags, that’s a bit more flexible than categories. For my blogs the comments are closed (mt_allow_comments), mt_allow_pings is open, and the real tasty bit is the trackbacks (mt_tb_ping_urls : simply urls separated with a blank space, just like in the wordpress form). I played with the Arrousi trackback class, that one has an autodiscover routine, so I can try and fetch a trackback url from the content page I am ‘using’.

I don’t work with enclosures, but to be complete I added it here.

That covers most data I want to send around a blog network. Very nice class, Incutio IXR.

Next week : more nonsense.

Posted in wordpress, xml-rpc and tagged , .


  1. Pingback: wp-popular.com » Blog Archive » juust ~ php oddities » xml rpc – remote posting with incutio wordpress ixr class

  2. You could certainly see your skills in the article you write.
    The world hopes for even more passionate writers like you who are not afraid to say how they believe.
    Always follow your heart.

Leave a Reply

Your email address will not be published. Required fields are marked *