2009/04/27

How to auto post to Wordpress

  1. Turn on remove_posting at http://yourdomain/wp-admin/options-writing.php
  2. Using below PHP code:
function wpPostXMLRPC($title,$body,$rpcurl,$username,$password,$categories=array(1)){
   $categories = implode(",", $categories);
   $XML = "<title>$title</title>".
   "<category>$categories</category>".
   "<body>$body</body>";
   $params = array('','',$username,$password,$XML,1);
   $request = xmlrpc_encode_request('blogger.newPost',$params);
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
   curl_setopt($ch, CURLOPT_URL, $rpcurl);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_TIMEOUT, 1);
   curl_exec($ch);
   curl_close($ch);
}

No comments:

Post a Comment