PHP: Curl未调用URL并得到错误号=0


PHP: Curl not called URL and got Error No =0

我正在开发一个SMS应用程序。我必须调用一个链接例如http://sendsms.com/send.php?mobile=45455&msg=hello发送短信

所以我用CURL的概念来发送短信。

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

问题是消息没有发送。我检查了SMS API服务器。也没有收到任何请求。所以唯一的问题是CURL可能不会调用服务器。我试图打印错误消息,我得到curl_errno($ch) is 0

请告诉我最好的方法

尝试通过POST发送请求:

curl_setopt($ch, CURLOPT_POST      ,1);