Reputation: 1
I have working SMS sending over gateway using CURL method. But If I include this character "&" in my message text area, it will send the message before this character only.
So how I could fix it to send messages including this character normally.
here is my code:
$from = "Gateway_username"; // SMS username
$token = "Gateway_password"; // SMS password
$option = $_REQUEST["option"];
$text = $_REQUEST["BulkSMS1__messageTextBox"];
if ($text == "") { } else {
$url = "http://awaljawaly.awalservices.com.sa:8001/Send.aspx";
$postfields = array ("REQUESTTYPE" => "SMSSubmitReq",
"Username" => "$from", "Password" => "$token", "MOBILENO" => "$d_mobile", "MESSAGE" => "$text");
if (!$curld = curl_init()) {
echo "Could not initialize cURL session.";
exit;
}
curl_setopt($curld, CURLOPT_POST, true);
curl_setopt($curld, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($curld, CURLOPT_URL, $url);
curl_setopt($curld, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($curld);
curl_close ($curld);
preg_match("/(.*)/",$output, $out);
}
This is a sample message:
Our Address: H&R Center.
Thanks in advance.
I have used this to fix my issue:
$text = str_replace('&', '%26', $_REQUEST["BulkSMS1__messageTextBox"]);
Upvotes: 0
Views: 997
Reputation: 1
I have used this to fix my issue:
$text = str_replace('&', '%26', $_REQUEST["BulkSMS1__messageTextBox"]);
Upvotes: 0
Reputation: 4019
See urlencode() -> http://php.net/manual/en/function.urlencode.php
<?php
$text = urlencode($_REQUEST["BulkSMS1__messageTextBox"]);
?>
Upvotes: 1
Reputation: 1246
You would want to encode the characters:
http://www.clockworksms.com/blog/the-gsm-character-set/
With this, try using:
utf8_encode()
The reason for this is that you're encoding for a mobile device, not a website, so using url encode will not work, compared to utf8 encode.
Upvotes: 1