6

我正在尝试从 PHP 执行 AT 命令。

我试过 exec() 和 shell_exec()

请不要建议第三方短信网关 我的客户不想透露他的私人信息并想从他自己的服务器发送短信。

我有一个 GSM 调制解调器连接到一个串行端口,我可以通过如图中的“腻子”访问它 腻子屏 1

我可以输入 AT 命令来发送短信,如下图所示。 在此处输入图像描述

我想通过 PHP 运行那些 AT 命令。

4

2 回答 2

14

嗨,我通过这个 php 代码在 Windows 8 上使用 php 类发送短信。

require "php_serial.class.php";
$serial = new phpSerial;
$serial->deviceSet("COM4");
$serial->confBaudRate(115200);

// Then we need to open it
$serial->deviceOpen();

// To write into
$serial->sendMessage("AT+CMGF=1\n\r"); 
$serial->sendMessage("AT+cmgs=\"+92234444444\"\n\r");
$serial->sendMessage("sms text\n\r");
$serial->sendMessage(chr(26));

//wait for modem to send message
sleep(7);
$read=$serial->readPort();
$serial->deviceClose();

PHP SERIAL 类链接

于 2013-12-10T08:06:09.400 回答
2

您只需要一个 RS232 通信类,例如这个 http://www.phpclasses.org/package/3679-PHP-Communicate-with-a-serial-port.html

或者,您也可以使用 fopen()

exec('mode COM1: baud=115200 data=8 stop=1 parity=n xon=on');
$fd = fopen('COM1:', O_RDWR);
fwrite($fd,chr(0).chr(1));
fclose($fd);
于 2013-04-09T13:23:07.817 回答