0

所以我正在尝试使用 cPanel API(XML) 登录界面并运行完整备份,

但是我总是得到相同的错误堆栈

> Fatal error:  Uncaught exception 'Exception' with message 'curl_exec threw error "couldn't connect to host" for
> https://37.111.11.1:2083/xml-api/cpanel?<all of the vars>' in
> /home/liamb/public_html/whmcs/backup_class.php:839 Stack trace:
> #0 /home/liamb/public_html/whmcs/backup_class.php(763): xmlapi->curl_query('https://37.26.1...', 'cpanel_xmlapi_u...',
> 'Authorization: ...')
> #1 /home/liamb/public_html/whmcs/backup_class.php(938): xmlapi->xmlapi_query('cpanel', Array)
> #2 /home/liamb/public_html/whmcs/backup_class.php(83): xmlapi->api1_query('a123', 'Fileman', 'fullbackup', Array)
> #3 /home/liamb/public_html/whmcs/backup.php(32): backup->add_cPanel()
> #4 {main}   thrown in /home/liamb/public_html/whmcs/backup_class.php on line 839

我不知道为什么会这样,我可以通过浏览器访问它,但是它强制使用 SSL,CURL 设置为处理未经验证的证书,但我认为这是它中断的地方,这是 CURL 代码

$curl = curl_init();

    // Set the URL
    curl_setopt($curl, CURLOPT_URL, $url);
    // Increase buffer size to avoid "funny output" exception
    curl_setopt($curl, CURLOPT_BUFFERSIZE, 131072);
    curl_setopt( $curl , CURLOPT_SSL_VERIFYHOST , 0 ); 
    curl_setopt( $curl , CURLOPT_SSL_VERIFYPEER , 0 );
    curl_setopt( $curl, CURLOPT_RETURNTRANSFER , 1 );

    // Pass authentication header
    $header[0] =$authstr .
        "Content-Type: application/x-www-form-urlencoded\r\n" .
        "Content-Length: " . strlen($postdata) . "\r\n" . "\r\n" . $postdata;

    curl_setopt( $curl, CURLOPT_HTTPHEADER , $header );

    $result = curl_exec($curl);
    echo "<pre>".print_r(curl_getinfo($curl),1)."</pre>";
    if ($result == false) {
        throw new Exception("curl_exec threw error \"" . curl_error($curl) . "\" for " . $url . "?" . $postdata );
    }
    curl_close($curl);
    return $result;

卷曲信息产生以下

  Array
(
    [url] => https://37.111.11.1:2083/xml-api/cpanel
    [content_type] => 
    [http_code] => 0
    [header_size] => 0
    [request_size] => 0
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 189.000809
    [namelookup_time] => 0.000163
    [connect_time] => 0
    [pretransfer_time] => 0
    [size_upload] => 0
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 0
    [download_content_length] => -1
    [upload_content_length] => -1
    [starttransfer_time] => 0
    [redirect_time] => 0
    [certinfo] => Array
        (
        )

    [redirect_url] => 
)

任何人都可以帮忙吗?卡在这上面好几天了!

更新:如果我尝试连接到 127.0.0.1 它可以工作!好吧,至少它带回了 XML 输出!

4

0 回答 0