2016-11-11 63 views
2
$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. 我怎样才能解决这个问题?XML-RPC请求对象错误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 
     ) 

) 
+2

哦终于我发现了确切的问题。其实这是https:协议问题的问题。我使用的代码不适用于https。我使用https的以下代码。 –

回答

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();