gpt4 book ai didi

wordpress - 需要一个代码示例来展示如何使用 Codeigniter 发布到 Wordpress

转载 作者:行者123 更新时间:2023-12-03 07:01:13 25 4
gpt4 key购买 nike

有人可以分享一个代码示例,展示如何使用 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>';
}
}

最佳答案

经过一番咬牙切齿,这似乎有效:

function doPost(){

$this->load->library('xmlrpc');

$bloguser = "theUserID";
$blogpass = "thePassword";
$blogid = 1;
$publishImmediately = TRUE;

$thePost = array(array('title' => array('this is the title','string'),
'description' => array('this is the description','string')
),
'struct');


$myPost = "my post";
//$this->xmlrpc->set_debug(TRUE);
$this->xmlrpc->server("http://url.to/xmlrpc.php", 80);
$this->xmlrpc->method('metaWeblog.newPost');

$request = array($blogid, $bloguser, $blogpass, $thePost, $publishImmediately);

$this->xmlrpc->request($request);
$result = $this->xmlrpc->send_request();

if ( !$result )
{
echo $this->xmlrpc->display_error();
}
else
{
echo '<pre>';
print_r($this->xmlrpc->display_response());
echo '</pre>';
}
}

重要的部分是注意实际帖子元素的结构。

关于wordpress - 需要一个代码示例来展示如何使用 Codeigniter 发布到 Wordpress,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1324360/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com