php api parameter not working

dkmarsh Source

Am am trying to call an API, however must have something wrong - The problem is that the parameter reply_callback does not appear to be working. I think it may be an encoding issue or something like that.

Please help.

The documentation for api is at https://app.wholesalesms.com.au/help/api

The code is

<?php


header('Content-type: text/plain; charset=utf-8');

function send_sms(){

$url = "https://app.wholesalesms.com.au/api/v2/send-sms.json"; 


//echo $content;

$content = "to=%2B64212465478&message=hello+david&reply_callback=https://www.phoenixsoftware.co.nz/smsreply.php";

$num_to = "+64212465478";
$message = "hello dave 652";

//$content = "to=".urlencode($num_to)."&message=".urlencode($message)."&reply_callback=".urlencode("https://www.phoenixsoftware.co.nz/smsreply.php");

$content = "to=".urlencode($num_to)."&message=".urlencode($message);

$content = "to=".urlencode($num_to)."&message=".urlencode($message)."&reply_callback=".urlencode("https://www.phoenixsoftware.co.nz/smsreply.php");

echo "content is" . $content . "<br>";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "7ad8487bf5b1ffe57asdf0cec4efa53184f1:97c720ab85038093dasdf292fc43053789b1");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
        array("Content-type: application/x-www-form-urlencoded"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

$json_response = curl_exec($curl);

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ( $status == 200 ) {
       echo "successful";
}else{
    die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl)); }



curl_close($curl);

$response = json_decode($json_response, true);

print_r($response);

}



send_sms();



?>
phpapi

Answers

comments powered by Disqus