<?php
wpPostXMLRPC('post','title',"articlebody",'http://yourdomain.com/xmlrpc.php','wordpressuser','wordpresspass','categoryname',$search_keyword,$which_site);
function wpPostXMLRPC($post_type,$title,$body,$rpcurl,$username,$password,$category,$search_keyword,$which_site,$keywords='',$encoding='UTF-8') {
if(trim($title)=='' || trim($body)==''){return;}
$body=utf8_decode($body);$title=utf8_decode($title);
$body = preg_replace('/[^(\x20-\x7F)]*/','', $body);$body = stripslashes( $body);
$title = preg_replace('/[^(\x20-\x7F)]*/','', $title);$title = stripslashes( $title);
$dateCreated = date("Y-m-d H:i:s" , strtotime("- 3 days", strtotime(date("Y-m-d H:i:s"))));
$title = htmlentities($title,ENT_NOQUOTES,$encoding);
$keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding);
$content = array(
'title'=>$title,
'description'=>$body,
'mt_allow_comments'=>0, // 1 to allow comments
'mt_allow_pings'=>0, // 1 to allow trackbacks
'post_type'=>$post_type,
'post_status'=>'publish',
'wp_author_id'=>'credit',
'mt_keywords'=>$keywords,
'categories'=>array($category),
'dateCreated' => $dateCreated
);
$ch = curl_init();
$params = array(0,$username,$password,$content,1);
$request = xmlrpc_encode_request('metaWeblog.newPost',$params);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_URL, $rpcurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$results = curl_exec($ch);
curl_close($ch);
$response = xmlrpc_decode(trim($results));
if ($response && xmlrpc_is_fault($response)) {
echo "xmlrpc: $response[faultString] ($response[faultCode])";
}else{
echo "The ARTICLE: ".$title." CREATED! keyword used for this article: ".$search_keyword."-".$which_site."-".$response."-";}
}
?>