这是我的代码,错误显示为curl错误:libcurl 中不支持或禁用协议"http">
<?php
//Please Enter Your Details
$user="mysite"; //your username
$password="12345"; //your password
$mobilenumbers="1234567890"; //enter Mobile numbers comma seperated
$message = "Your unique id is 5544"; //enter Your Message
$senderid="WEBSMS"; //Your senderid
$url=" http://sapteleservicess.in/SMS_API/sendsms.php"; $message = urlencode($message);
$ch = curl_init();
if (!$ch){die("Couldn't initialize a cURL handle");}
echo "vannu1";
$ret = curl_setopt($ch, CURLOPT_URL,$url);
echo "vannu2";
curl_setopt ($ch, CURLOPT_POST, 1);
echo "vannu3";
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
echo "vannu4";
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
echo "vannu5";
curl_setopt ($ch, CURLOPT_POSTFIELDS,"username=$user&password=$password&mobile=$mobilenumbers& message=$message&sendername=$senderid&routetype=1");
echo "vannu6";
$ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
echo "vannu7";
//If you are behind proxy then please uncomment below line and provide your proxy ip with port. // $ret = curl_setopt($ch, CURLOPT_PROXY, "PROXY IP ADDRESS:PORT");
$curlresponse = curl_exec($ch); // execute
//if(curl_errno($ch))
echo 'curl error : '. curl_error($ch);
if (empty($ret)) {
echo "vannu8";
// some kind of an error happened
die(curl_error($ch));
echo "vannu9";
curl_close($ch); // close cURL handler
} else {
echo "vannu10";
$info = curl_getinfo($ch); curl_close($ch); // close cURL handler
echo "vannu11";
echo $curlresponse; //echo "Message Sent Succesfully" ;
}
?>
当URL前面有一些空白(如回车或换行(时,就会发生这种情况。所以curl会感到困惑。如果错误键入http
或https
,也可能发生这种情况。