本文介绍了执行AT命令在php中发送短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从 PHP 执行 AT 命令.
I am trying to execute AT commands from PHP.
我试过 exec() 和 shell_exec()
I tried exec() and shell_exec()
请不要推荐第三方短信网关,我的客户不想透露他的私人信息,想从他自己的服务器发送短信.
Please don't suggest third party SMS gateway my client doesn't want to disclose his private information and wants to send SMS from his own server.
我有一个 GSM 调制解调器连接到一个串行端口,我可以通过腻子"访问,如图
I have a GSM modem attach to a serial port which I can access through "putty" like in fig
我可以输入 AT 命令来发送短信,如下图所示.
And I can enter AT commands to send SMS like in fig below.
我想通过 PHP 运行那些 AT 命令.
I want to run those AT commands through PHP.
推荐答案
我正在通过此 php 代码在 windows 8 上使用 php 类发送短信.
Hi I am sending sms using php class on windows 8 by this php code.
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
");
$serial->sendMessage("AT+cmgs="+92234444444"
");
$serial->sendMessage("sms text
");
$serial->sendMessage(chr(26));
//wait for modem to send message
sleep(7);
$read=$serial->readPort();
$serial->deviceClose();
这篇关于执行AT命令在php中发送短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!