gpt4 book ai didi

php - 使用 PHP 的阿拉伯语 Gammu SMS 无法发送

转载 作者:太空宇宙 更新时间:2023-11-04 12:04:59 24 4
gpt4 key购买 nike

我正在尝试使用 PHP 在我的服务器上拥有自己的 SMS 网关。我已经安装了 Gammu,并且我配置了权限和设置。现在它可以使用以下原型(prototype)脚本正常发送 SMS:

<?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
}
?>

但是,使用英文文本(拉丁文)SMS 时一切正常,但是尝试发送阿拉伯文 SMS 时,尽管运营商回复为 OK,但仍无法发送到目的地,

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

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

我的服务器是 Ubuntu Linux 16.04。

更新:

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

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.

最佳答案

终于在多次阅读this section of documentation之后经过多次尝试,我发现正确的命令选项如下所示:

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

在上面的示例中,使用了 -textutf8 而不是 -text。另外,请注意 -c 配置文件路径是可选的,以确保将使用什么设备。

关于php - 使用 PHP 的阿拉伯语 Gammu SMS 无法发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51048762/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com