duanbanzhi4419 2017-11-05 20:49
浏览 945

cURL返回一个空字符串

I have following code which returns an empty string (in variable $result)

$createdURL = "https://telenorcsms.com.pk:27677/corporate_sms2/api/sendsms.jsp?session_id=123&to=92315&text=test&mask=1"
curl_setopt($ch, CURLOPT_URL, "$createdURL");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml; charset=utf-8')) ;
curl_setopt($ch, CURLOPT_HEADER, 0);
$result = curl_exec($ch);
echo var_dump($result);
if(curl_errno($ch)){
        echo 'Curl error: ' . curl_error($ch);
}
curl_close($ch);

Whereas when I run the link given in first line in browser address bar it returns following XML.

<corpsms>
    <command>Submit_SM</command>
    <data>Error 102</data>
    <response>Error</response>
</corpsms>

Please help where am I wrong.

  • 写回答

3条回答 默认 最新

  • dsd30433 2017-11-05 20:51
    关注

    You can enable the CURLOPT_VERBOSE option:

    curl_setopt($ch, CURLOPT_VERBOSE, true);
    

    When CURLOPT_VERBOSE is set, output is written to STDERR or the file specified using CURLOPT_STDERR. The output is very informative.

    You can also use tcpdump or wireshark to watch the network traffic.

    评论

报告相同问题?

悬赏问题

  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿