有没有人可以分享一个代码示例,展示如何使用 CodeIgniter xml-rpc 库向 Wordpress 发布基本博客文章?
到目前为止,我有这个,尽管我使用了正确的组合,但它总是导致“登录/密码组合错误”。
function doPost(){
$this->load->library('xmlrpc');
$bloguser = "theUserid";
$blogpass = "thePassword";
$blogid = 0; //I've tried 0 and 1 here.
$post['title'] = "The title of a new post";
$post['description'] = "The body of the post.";
$this->xmlrpc->server("http://localhost/blog/xmlrpc.php", 80);
$this->xmlrpc->method('metaWeblog.newPost');
$this->xmlrpc->request = array($blogid, $bloguser, $blogpass, $post, TRUE);
if ( ! $this->xmlrpc->send_request())
{
echo $this->xmlrpc->display_error();
}
else
{
echo '<pre>';
print_r($this->xmlrpc->display_response());
echo '</pre>';
}
}