$postcontent = array(
'post_type' => 'post',
'post_status' => $post_status,
'post_title' => $post_title,
'post_name' => $post_title,
'post_content' => $post_content,
'post_thumbnail' => $image_returnInfo['id']
// 'terms_names'=> array( 'category' => $category_battery),
);
$res = $client -> query('wp.newPost',1, $usr, $pwd, $postcontent);
$postID = $client->getResponse();
print_r($client);
虽然我试图从xmlrpc wordpress api插入帖子但我得到了错误32300。 我怎么解决这个问题?
我得到了以下结果。
IXR_Client Object
(
[server] => battery.kis-com.ch
[port] => 80
[path] => /battery-station/xmlrpc.php
[useragent] => The Incutio XML-RPC PHP Library
[response] =>
[message] =>
[debug] =>
[timeout] => 15
[headers] => Array
(
[Host] => battery.kis-com.ch
[Content-Type] => text/xml
[User-Agent] => The Incutio XML-RPC PHP Library
[Content-Length] => 781
)
[error] => IXR_Error Object
(
[code] => -32300
[message] => transport error - HTTP status code was not 200
)
)
答案 0 :(得分:2)
请点击此链接(https://codex.wordpress.org/XML-RPC_WordPress_API)。 更改端口可能会有所帮助,因为所有端口都采用默认值80。 将其更改为端口号为81或其他数字可能会有所帮助。
答案 1 :(得分:1)
这是我发现的wordpress的支持票。 https://mu.wordpress.org/forums/topic/5997
原来我失去了记忆 PHP致命错误:允许的内存大小为8388608字节 将php.ini更改为允许10M似乎可以修复它。 请试一试。
答案 2 :(得分:1)
实际上问题出在https协议上。我使用以下代码进行https。
include_once( ABSPATH . WPINC . '/class-IXR.php' );
include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' );
$usr = '****';
$pwd = '*****';
$xmlrpc = 'https://test.ch/xmlrpc.php';
//echo $xmlrpc;
//echo ABSPATH . WPINC . '/class-IXR.php' ;
// $client = new IXR_Client($xmlrpc);
$client = new WP_HTTP_IXR_CLIENT($xmlrpc);
$postcontent = array(
'post_type' => 'post',
// 'post_status' => 'test',
'post_title' => 'test',
'post_content' => 'test'
);
$res = $client -> query('wp.newPost',1, $usr, $pwd, $postcontent);
$postID = $client->getResponse();