使用 PHP 的阿拉伯语 Gammu 短信无法发送 [英] Gammu SMS in Arabic using PHP does not be delivered

查看:31
本文介绍了使用 PHP 的阿拉伯语 Gammu 短信无法发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 PHP 在我的服务器上拥有自己的 SMS 网关.我已经安装了 Gammu 并且我很好地配置了权限和设置.现在它使用以下原型脚本发送短信:

I'm trying to have my own SMS gateway on my server using PHP. I have installed Gammu and I configured the permissions and settings well. Now it send SMS fine using the following prototype script:

<?php
$text = $_POST['text'];
$numb = $_POST['numb'];
if ($text != '' && $numb != ''){
  //die('echo "'.$text.'" | gammu --sendsms TEXT '.$numb);
  echo "<pre>";
  //die(passthru('whoami'));
  $command = 'echo "'.$text.'" | gammu --sendsms TEXT '.$numb.' >> '.__DIR__.'/smslog.txt';//.'" | gammu --sendsms TEXT '.$numb;

  echo passthru($command);
  //echo $command;
}
else{
  ?>
  <form method="POST">
  <input type="text" name="numb">
  <textarea name="text"></textarea>
  <input type="submit">
  </form>
  <?php
}
?>
However, everything works fine with English text (Latin) SMS, but trying to send Arabic SMS failed to be delivered to the destination in spite of carrier respond with OK,

但是,使用英文文本(拉丁文)SMS 一切正常,但尽管运营商回复 OK,但尝试发送阿拉伯语 SMS 却未能送达目的地,

Sending SMS 1/1....waiting for network answer..OK, message reference=18

Also, I noticed that, from terminal, using the same gammu command with Arabic text, it delivered well, but with ?? ??????? ??? text representation. I am, partially, believe that it is encoding issue, but I have no idea how to solve it.  

另外,我注意到,从终端,使用相同的 gammu 命令和阿拉伯文本,它交付得很好,但是使用 ???????????? 文本表示.我部分认为这是编码问题,但我不知道如何解决.

My server is Ubuntu Linux 16.04.

我的服务器是 Ubuntu Linux 16.04.

I have figured out how to send Arabic text from the bash using gammu command like the following in which -unicode option is used:

我已经想出了如何使用如下所示的 gammu 命令从 bash 发送阿拉伯文本,其中使用了 -unicode 选项:

gammu sendsms TEXT 022222222 -unicode -text "نص عربي"



<块引用>

然而,上面提到的脚本发送了阿拉伯语消息,但在手机上看起来像333333333.我不知道什么字符串通过以下方式发送到命令流时发生passthru 并且我也尝试使用 exec 并且结果相同.

However, the script regarded above, send the Arabic message but it look something like 333333333 on the phone. I have no any idea about what occurred to the string when it send to the command stream via passthru and I tried to use exec also and the same result.

推荐答案

在多次阅读文档的这一部分 和多次尝试,我发现正确的命令选项如下所示:

Finally after many reading of this section of documentation and many tries, I have found the correct command's options to be like the following:

gammu -c /etc/gammurc sendsms  TEXT 02222000 -unicode -textutf8 "نص عربي"

在上面的例子中,使用 -textutf8 代替 -text.另外,请注意 -c 配置文件路径是可选的,以确保将要使用的设备.

In the above example -textutf8 is used instead of -text. Also, notice that -c configurations file path is supplied optionally to just make sure what device is going to be used.

这篇关于使用 PHP 的阿拉伯语 Gammu 短信无法发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆