Gammu SMS in Arabic using PHP does not be delivered

本秂侑毒 提交于 2019-12-24 23:37:21

问题


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,

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.

My server is Ubuntu Linux 16.04.

Update:

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 sendsms TEXT 022222222 -unicode -text "نص عربي"

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.


回答1:


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 "نص عربي"

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.



来源:https://stackoverflow.com/questions/51048762/gammu-sms-in-arabic-using-php-does-not-be-delivered

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!