dongyong1897 2013-04-11 07:58
浏览 227
已采纳

PHP:Curl没有调用URL并且得到错误No = 0

I am developing one SMS application. I have to call one link for eg http://sendsms.com/send.php?mobile=45455&msg=hello for sending SMS

so I used CURL concept to send sms.

$ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    $options = array(
        CURLOPT_RETURNTRANSFER => true, // return web page
        CURLOPT_HEADER => false, // don't return headers
        CURLOPT_FOLLOWLOCATION => true, // follow redirects
        CURLOPT_ENCODING => "", // handle all encodings
        CURLOPT_AUTOREFERER => true, // set referer on redirect
        CURLOPT_CONNECTTIMEOUT => 15, // timeout on connect
        CURLOPT_TIMEOUT => 15, // timeout on response
        CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
    );

    curl_setopt_array($ch, $options);
    $content = curl_exec($ch);
    $err = curl_errno($ch);
    $errmsg = curl_error($ch);
    $header = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);

    $output ="Error:".$err." ErrMsg:".$errmsg." Header:".  json_encode($header);

The Problem is message is not sending. I checked the SMS API server. And There also no request is received. So the only problem is CURL may not calling the server. I tried to print the Error msg and I got curl_errno($ch) is 0

please provide me the best way to do this

  • 写回答

1条回答 默认 最新

  • dsepcxw181184853 2013-04-11 08:08
    关注

    Try to send request by POST:

    curl_setopt($ch, CURLOPT_POST      ,1);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何修改pca中的feature函数
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R
  • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法