WordPress 利用XML-RPC写远程日志,支持Custom Fields
采用metaWeblog.newPost而不是Weblog.newPost方法,支持添加Custom Fields字段
function post($result){ include("xmlrpc.inc"); $GLOBALS['xmlrpc_internalencoding'] = 'UTF-8'; $c = new xmlrpc_client("xmlrpc.php","example.com", 80); $content['title']="title"; $content['description']="content"; $content['mt_keywords']="tag1,tag2"; $content['wp_password']=""; $content['categories'] = array("label"); $content['custom_fields'] = array( array( 'key' => 'city', 'value' => 'Sacramento' ) ); $x = new xmlrpcmsg("metaWeblog.newPost", array(php_xmlrpc_encode("1"), php_xmlrpc_encode("admin"), php_xmlrpc_encode('123456'), php_xmlrpc_encode($content), php_xmlrpc_encode("1"))); $c->return_type = 'phpvals'; $r =$c->send($x); if ($r->errno=="0") echo "success,ID:".$r->val; else { echo "fail";; print_r($r); } }
抱歉,暂停评论。