php - CURL POSTFIELDS to contain "&" character -
i have working sms sending on gateway using curl method. if include character "&" in message text area, send message before character only.
so how fix send messages including character normally.
here 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 sample message:
our address: h&r center.
thanks in advance.
i have used fix issue:
$text = str_replace('&', '%26', $_request["bulksms1__messagetextbox"]);
see urlencode() -> http://php.net/manual/en/function.urlencode.php
<?php $text = urlencode($_request["bulksms1__messagetextbox"]); ?>
Comments
Post a Comment