I am using curl reques to get report of sms but facing some issues. i have also ckecked by encoding url but still same issue.
400 bad request is being shown.

```
$url="http://api.smscountry.com/smscwebservices_bulk_reports.aspx?user=&passwd=&fromdate=19/04/2017 00:00:00&todate=19/04/2017 23:59:59&jobno=60210892";  //callbackURL=http://www.jouple.com/marketing/public/save/sms
$ch = curl_init();
if (!$ch){
    die("Couldn't initialize a cURL handle");
}
$ret = curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
// curl_setopt ($ch, CURLOPT_POSTFIELDS,
// "User=$user&passwd=$password&sid=$senderid");
// $ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//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

// print_r($ch);die;
if(curl_errno($ch))
    echo 'curl error : '. curl_error($ch);
if (empty($ret)) {
// some kind of an error happened
    die(curl_error($ch));
    curl_close($ch); // close cURL handler
} else {
    $info = curl_getinfo($ch);
    curl_close($ch); // close cURL handler

}

```
['https://Stackoverflow.com/questions/43490729', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4054369/']
This happens when you have whitespaces in URL. You have to escape url. Follow the below code

```
<?php
$url="http://api.smscountry.com/smscwebservices_bulk_reports.aspx/";  //callbackURL=http://www.jouple.com/marketing/public/save/sms
$url2= "?user=&passwd=&fromdate=19/04/2017 00:00:00&todate=19/04/2017 23:59:59&jobno=60210892";
        $ch = curl_init();
        $url = $url . curl_escape($ch, $url2);
        if (!$ch){
            die("Couldn't initialize a cURL handle");
        }
        $ret = curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt ($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        // curl_setopt ($ch, CURLOPT_POSTFIELDS,
        // "User=$user&passwd=$password&sid=$senderid");
        // $ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        //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

        // print_r($ch);die;
        if(curl_errno($ch))
            echo 'curl error : '. curl_error($ch);
        if (empty($ret)) {
        // some kind of an error happened
            die(curl_error($ch));
            curl_close($ch); // close cURL handler
        } else {
            $info = curl_getinfo($ch);
            curl_close($ch); // close cURL handler

        }

```

After this you will face a error invalid content length. Uncomment the line CURLOPT\_POSTFIELDS and pass correct credentials. Definitely it will work.
You can add just urlencode() to your parameters like msg and mobile :

```
    $sms = "Dear User, Your OTP for trip is $otp CSPL"; 
    $sms = urlencode($sms);
    $mobile =  urlencode($mobile);
    $url = "yoururl";
    $ch  = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    $responseJson = curl_exec($ch);
    $httpcode     = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

```