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:
-
include_once('wp-includes/class-IXR.php');
-
-
//just give us your endpoint and we'll take it from there Sparky…
-
$client = new IXR_Client('http://tryout.blacknorati.com/xmlrpc.php');
-
-
// xml rpc post function form :
-
// metaWeblog.newPost( blog_id, username, password, struct, publish )
-
-
//struct = structure for post data
-
$post['title'] = 'test titel';
-
$post['description'] = 'test';
-
$post['categories'] = array("frontpage");
-
-
//use 'query' to interact with the server, set publish to 0 (draft) for now
-
if (!$client->query('metaWeblog.newPost', 6, 'user', 'password', $post, 0)) {
-
die('Something went wrong – '.$client->getErrorCode().' : '.$client->getErrorMessage());
-
}
-
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.
-
$post['categories'] = array("frontpage");
-
$post['mt_keywords']='key1, key2';
-
$post["mt_allow_comments"] ='closed';
-
$post['mt_allow_pings']='open';
-
//$post['mt_tb_ping_urls'] ='url url url';
-
//$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.
Pingback: wp-popular.com » Blog Archive » juust ~ php oddities » xml rpc – remote posting with incutio wordpress ixr class
You Solve My WordPress Post Via Remote
Thank You