简体   繁体   English

如何使用PHP在印地文发送短信

[英]How to send sms in hindi using php

i have successfully integrated the bulk sms gateway and its sending the message too. 我已成功集成了批量短信网关及其发送消息。 But,now i am trying to send the sms in hindi. 但是,现在我正试图在印地文发送短信。 When i put hindi message like 当我把印地语的消息像

$message = 'बधाई हो! मेरी वेबसाइट में आपका स्वागत है, अब आप हमारे सदस्य हैं। आपका url है '.$url.' ';

It shows me ?????????????? 它告诉我????????????? ???????? ???????? ????? ????? like this. 像这样。

Here is my php code: 这是我的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("&lt;","&gt;"),$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);

}
?>

I have tried the script : 我试过这个剧本:

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);
}

but its not working. 但它不起作用。 Please help me out. 请帮帮我。 Thanks 谢谢

First, you need to know, that not all Bulk SMS provider support or allow Unicode Message. 首先,您需要知道,并非所有批量SMS提供程序都支持或允许Unicode消息。 There are different encoding for each SMS format. 每种SMS格式都有不同的编码。 So far I found SMS.to allow Unicode SMS sending, which mean you can send SMS in Hindi or any other regional language. 到目前为止,我发现SMS.to允许Unicode短信发送,这意味着您可以用印地语或任何其他区域语言发送短信。

转码选项

They count 70 Unicode characters as 1 SMS, which is far better from most of the Bulk SMS providers, which will allow only 30 characters in 1 SMS. 它们将70个Unicode字符计为1个短信,这比大多数批量短信服务提供商要好得多,后者只允许1个短信中的30个字符。 They also offer REST API: https://sms.to/api-docs so it's easy to integrate. 他们还提供REST API: https//sms.to/api-docs,因此易于集成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM