我已经成功集成了批量sms网关及其发送消息。但是,现在我正在尝试向印度语发送短信。当我把印地文信息放进去
$message = 'बधाई हो! मेरी वेबसाइट में आपका स्वागत है, अब आप हमारे सदस्य हैं। आपका url है '.$url.' ';
它告诉我??????????????? ????????? ??????这样。
这是我的php代码:
<?php
include 'config.php';
if(isset($_POST['save'])){
$user = "xxxxxxxxxxxx";
$password = "xxxxxxxxxxxxx";
$senderid = "xxxxxxxxxxxxxx";
$checkbox = $_POST['check'];
for($i=0;$i<count($checkbox);$i++){
$del_id = $checkbox[$i];
mysqli_query($conn,"UPDATE inventory_details SET status='0' WHERE id='".$del_id."'");
}
}
$smsurl = "http://kit19.com/ComposeSMS.aspx?";
function httpRequest($url){
$pattern = "/http...([0-9a-zA-Z-.]*).([0-9]*).(.*)/";
preg_match($pattern,$url,$args);
$in = "";
$fp = fsockopen($args[1],80, $errno, $errstr, 30);
if (!$fp) {
return("$errstr ($errno)");
} else {
$args[3] = "C".$args[3];
$out = "GET /$args[3] HTTP/1.1\r\n";
$out .= "Host: $args[1]:$args[2]\r\n";
$out .= "User-agent: Website\r\n";
$out .= "Accept: */*\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
$in.=fgets($fp, 128);
}
}
fclose($fp);
return($in);
}
function SMSSend($phone, $msg, $debug=false){
global $user,$password,$senderid,$smsurl;
$url = 'username='.$user;
$url.= '&password='.$password;
$url.= '&sender='.$senderid;
$url.= '&to='.urlencode($phone);
$url.= '&message='.urlencode($msg);
$url.= '&priority=1';
$url.= '&dnd=1';
$url.= '&unicode=0';
$urltouse = $smsurl.$url;
if ($debug) { echo ""; }
$response = httpRequest($urltouse);
if ($debug) {
str_replace(array("<",">"),array("<",">"),$response).
"</pre><br>"; }
return($response);
}
$checkbox = $_POST['check'];
for($i=0;$i<count($checkbox);$i++){
$del_id = $checkbox[$i];
$PrimaryMobile = mysqli_query($conn,"SELECT * FROM inventory_details WHERE id='".$del_id."'");
while($row = mysqli_fetch_array($PrimaryMobile)) {
$PrimaryMobile_no = $row['PrimaryMobile_no'];
$firm_name = $row['firm_name'];
$firm_name = urldecode($firm_name);
$firm_name = str_replace(' ', '-', $firm_name);
$firm_name = str_replace('&', '-', $firm_name);
$firm_name = str_replace('(', '-', $firm_name);
$firm_name = str_replace(')', '-', $firm_name);
# are you missing a / here ???
$url = 'http://www.example.com/' . urlencode($del_id) . '-' . urlencode($firm_name);
$message = 'बधाई हो! मेरी वेबसाइट में आपका स्वागत है, अब आप हमारे सदस्य हैं। आपका url है '.$url.' ';
}
$debug = true;
SMSSend($PrimaryMobile_no,$message,$debug);
}
?>
我已经尝试了脚本:
public function utf8_to_unicode($str) {
$unicode = array();
$values = array();
$lookingFor = 1;
for ($i = 0; $i < strlen($str); $i++) {
$thisValue = ord($str[$i]);
if ($thisValue < 128) {
$number = dechex($thisValue);
$unicode[] = (strlen($number) == 1) ? '%u000' . $number : "%u00" . $number;
} else {
if (count($values) == 0)
$lookingFor = ( $thisValue < 224 ) ? 2 : 3;
$values[] = $thisValue;
if (count($values) == $lookingFor) {
$number = ( $lookingFor == 3 ) ?
( ( $values[0] % 16 ) * 4096 ) + ( ( $values[1] % 64 ) * 64 ) + ( $values[2] % 64 ) :
( ( $values[0] % 32 ) * 64 ) + ( $values[1] % 64
);
$number = dechex($number);
$unicode[] =
(strlen($number) == 3) ? "%u0" . $number : "%u" . $number;
$values = array();
$lookingFor = 1;
} // if
} // if
}
return implode("", $unicode);
}
,但不起作用。请帮帮我。谢谢
答案 0 :(得分:0)
首先,您需要知道,并非所有的批量SMS提供程序都支持或允许Unicode消息。每种SMS格式都有不同的编码。 到目前为止,我发现SMS。允许发送Unicode SMS,这意味着您可以用印地语或任何其他区域性语言发送SMS。
他们将70个Unicode字符视为1条SMS,这比大多数Bulk SMS提供程序要好得多,后者在1条SMS中仅允许30个字符。他们还提供REST API:https://sms.to/api-docs,因此易于集成。