Execute AT commands to send sms in php

南笙酒味 提交于 2019-11-29 00:16:06

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\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 class Link

You just need a RS232 communication class such as this one http://www.phpclasses.org/package/3679-PHP-Communicate-with-a-serial-port.html

Alternatively you can also use 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);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!