卷曲请求在实时服务器中不起作用

时间:2018-03-06 05:54:20

标签: php curl

我使用此功能从网络服务获取数据

function get_on_going_vehicle_number($vehicle_category) {

    $xml_data = '<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v1="http://schemas.asdasdasd.com/xsdabcdf/v1">

 <soapenv:Header/>
 <soapenv:Body>
 <v1:GetOnGoingVehicleNo>
 <v1:vehicleCategory>' . $vehicle_category . '</v1:vehicleCategory>
 </v1:GetOnGoingVehicleNo>
 </soapenv:Body>
</soapenv:Envelope>';



    $URL = "http://api.somegate.vfg.lk:8580/Getsomething/1.0";

    $ch = curl_init($URL);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//        curl_setopt($ch, CURLOPT_MUTE, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: text/xml',
        'Authorization: Bearer 7655a410-d019-3f09-b214-08c40e737af0'
    ));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
//        curl_setopt($ch, CURLOPT_HTTPHEADER, array());
    curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);

    if (curl_error($ch)) {
        echo 'error:' . curl_error($ch);
        exit;
    }
    curl_close($ch);
}

在localhost中执行此操作后,它工作正常,而不是在我的实时服务器中。

当我包括这个

if (curl_exec($curl) === FALSE) {
   die("Curl Failed: " . curl_error($curl));
} else {
   return curl_exec($curl);
}

它说could not connect to host

所以请告诉我原因。感谢

0 个答案:

没有答案
相关问题