Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

curl error : Protocol " http" not supported or disabled in libcurl

Tags:

php

curl

This is my code and the error is showing as curl error : Protocol " http" not supported or disabled in libcurl

<?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" ;

}
?>
like image 596
Deepu Avatar asked Sep 02 '25 10:09

Deepu


1 Answers

This occurs when you have some whitespace (such as return or newline) before the URL. So curl gets confused. It can also occur if you misstype http or https.

like image 78
Dan Anderson Avatar answered Sep 04 '25 00:09

Dan Anderson