doumu6941 2018-03-06 05:54
浏览 22

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

I'm using this function for get data from web service

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

after executing this in localhost it works perfect and not in my live server.

when I includ this

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

it says could not connect to host

so please tell me the reason for this. Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?