keywords: ip pbx voip gateway gsm gateway

×

Notice

The forum is in read only mode.
× Questions about VS-GW2120/GW1600/GW1202 and WGW1002G GSM Series VoIP Gateway

Error in sending sms using HTML to SMS API

7 years 8 months ago #11176 by lindali
Hi,

Sorry for it. It's a known problem. When you need use " double quote, please use ' single quote instead of it.
7 years 8 months ago #11179 by Bootsector
The API is used in our sms gateway so I cannot control how the users compose their sms message.

Hopefully your developer will fix the message value in JSON report to return a value with backslashes before characters that need to be escaped like single quote ('), double quote ("), backslash (\).
7 years 8 months ago - 7 years 8 months ago #11180 by lindali
Hi sir,

We will fix it in the future. For now, please use "report=string" instead of JSON.
Picture below shows you the result I test in my place.



sendsms.php is my test script for you to refer to.

<?php

function sendSMS($ip,$phonenumber,$message)
{
$username = "smsuser";
$password = "smspwd";
//$port = "";
//$report = "";
//$timeout = "";
$message =urlencode(mb_convert_encoding($message, 'utf-8', "auto"));
$url = "http://$ip/sendsms?username=$username&password=$password&phonenumber=$phonenumber&message=$message&report=string";
//echo "$url<br>";
$link = curl_init();
curl_setopt($link, CURLOPT_HEADER, 0);
curl_setopt($link, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($link, CURLOPT_URL, $url);
$response = curl_exec($link);
curl_close($link);

echo $response."<br>";

$array = explode("\n",strchr($response,"result"));

foreach ($array as $key => $value) {
echo $array[$key]."<br>";
}

$report = substr($array[0],7);
echo $report;

if ($report == "success") {
echo '<center><p style="font-size:30pt;color:red;">SMS Sent successfully!<p></center>';
} elseif ($report == "sending") {
echo '<center><p style="font-size:30pt;color:red;">SMS is sending, please check later!<p></center>';
} else {
echo '<center><p style="font-size:30pt;color:red;">SMS is failed, please check your device or settings!<p></center>';
echo "<br>";
}
}

$ip = $_POST["ip"];
$phonenumber = $_POST["phonenumber"];
$message = $_POST["message"];

sendSMS($ip,$phonenumber,$message);


Wish this will help you.

Best regards,
email: This email address is being protected from spambots. You need JavaScript enabled to view it.
skype: linda.li258
Attachments:
7 years 8 months ago #11181 by Bootsector
That's a great help! Appreciated. Thank you.
7 years 8 months ago - 7 years 8 months ago #11182 by lindali
Hi sir,

Thanks for your feedback.
If you use JSON report format, it's allowed to send sms with double quote( " ), single quote( ' ), backslash( \ ) too. Here below is the script I use for test.

<?php

function sendSMS($ip,$phonenumber,$message)
{
$username = "smsuser";
$password = "smspwd";
//$port = "";
//$report = "";
//$timeout = "";
$message =urlencode(mb_convert_encoding($message, 'utf-8', "auto"));
$url = "http://$ip/sendsms?username=$username&password=$password&phonenumber=$phonenumber&message=$message";
//echo "$url<br>";
$link = curl_init();
curl_setopt($link, CURLOPT_HEADER, 0);
curl_setopt($link, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($link, CURLOPT_URL, $url);
$response = curl_exec($link);
curl_close($link);
echo '<p style="font-size:15pt;color:blue;">Response<p>'.$response."<br>";

$report = explode("\"",strchr($response,"result"))[2];
echo '<p style="font-size:15pt;color:blue;">Response<p>'.$report."<br>";


if ($report == "success") {
echo '<center><p style="font-size:30pt;color:red;">SMS Sent successfully!<p></center>';
} elseif ($report == "sending") {
echo '<center><p style="font-size:30pt;color:red;">SMS is sending, please check later!<p></center>';
} else {
echo '<center><p style="font-size:30pt;color:red;">SMS is failed, please check your device or settings!<p></center>';
echo "<br>";
}
}

$ip = $_POST["ip"];
$phonenumber = $_POST["phonenumber"];
$message = $_POST["message"];

sendSMS($ip,$phonenumber,$message);
?>


Attachments:
The following user(s) said Thank You: Bootsector
Time to create page: 0.399 seconds
Powered by Kunena Forum