curl错误:libcurl中不支持或禁用协议“ http”

时间:2018-08-02 12:06:40

标签: php curl

这是我的代码,错误显示为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" ;

}
?>

1 个答案:

答案 0 :(得分:0)

当URL前面有一些空格(例如return或换行符)时,会发生这种情况。所以卷曲变得困惑。如果您输错了httphttps的类型,也会发生这种情况。