致命错误:未捕获的异常'异常'消息' curl_exec抛出错误'

时间:2014-06-13 10:29:16

标签: php json curl

我在cpanel中执行时收到此错误'curl_exec throw error'。

Fatal error: Uncaught exception 'Exception' with message 'curl_exec threw error "couldn't connect to host" for http://192.178.1.678:2982/json-api/cpanel?domain=bconnect&user=cptest&cpanel_jsonapi_module=Email&cpanel_jsonapi_func=listpopswithdisk&cpanel_jsonapi_apiversion=2' in /home/myproject/public_html/class/xmlapi.php:704 Stack trace: #0 /home/myproject/public_html/class/xmlapi.php(626): xmlapi->curl_query('http://192.178....', 'domain=bconnect...', 'Authorization: ...') #1 /home/myproject/public_html/class/xmlapi.php(845): xmlapi->xmlapi_query('cpanel', Array) #2 /home/bconn3k2/public_html/controller/UserController.class.php(2310): xmlapi->api2_query('cptest', 'Email', 'listpopswithdis...', Array) #3 /home/myproject/public_html/controller/UserController.class.php(1098): UserController->mailaccexist('sample') #4 /home/myproject/public_html/nesote/library/Mail/Main.class.php(144): UserController->registrationAction() #5 /home/myproject/public_html/index.php(22): main->dispatch() #6 {main} thrown in /home/myproject/public_html/class/xmlapi.php on line 704

CURL代码在本地工作正常。任何人都可以告诉我服务器的错误 这是我的CURL代码

$curl = curl_init();
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    // Return contents of transfer on curl_exec
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    // Allow self-signed certs
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    // Set the URL
    curl_setopt($curl, CURLOPT_URL, $url);
    // Increase buffer size to avoid "funny output" exception
    curl_setopt($curl, CURLOPT_BUFFERSIZE, 131072);

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

    curl_setopt($curl, CURLOPT_POST, 1);

    $result = curl_exec($curl);
    if ($result == false) {
        throw new Exception("curl_exec threw error \"" . curl_error($curl) . "\" for " . $url . "?" . $postdata );
    }
    curl_close($curl);
    return $result;

0 个答案:

没有答案