PHP код:
function to_wp($blog_url,$login,$pass,$category,$title,$article_text){
require_once 'xmlrpc.inc';
$c = new xmlrpc_client("xmlrpc.php", $blog_url);
if ($category == "") $category = "Uncategorized";
$content['title']=$title;
$content['description']=$article_text;
$content['categories'] = array($category);
$x = new xmlrpcmsg("metaWeblog.newPost",
array(php_xmlrpc_encode("1"),
php_xmlrpc_encode($login),
php_xmlrpc_encode($pass),
php_xmlrpc_encode($content),
php_xmlrpc_encode("1")
)
);
$c->return_type = 'phpvals';
$r = $c-> send($x);
if ($r->errno=="0"){
echo "Successfully Posted\n";
print_r($r);
return "success";
}
else {
echo "There are some error\n";
print_r($r);
return "error";
}
}