为什么我写的代码不发送gsm AT命令

时间:2014-07-16 10:46:02

标签: php windows gsm

我正在尝试从我的vista pc发送短信。我从“命令窗口”尝试了AT命令并发送了短信。然后,我写了PHP代码从PHP发送短信;它打开端口,但它不发送短信。

 $device = "COM14";
 exec("mode $device : BAUD=9600 PARITY=n DATA=8 STOP=1");

 $comport = fopen($device, "w+");

 if ($comport === false){
    die("Failed opening com port<br/>");
 }else{
    echo "Com port is open<br/>";
 }

 $smsText="Test message";

 $atcmd1 ='AT+CMGF=1 \r\n';
 $atcmd2 ='AT+CMGS=\"05324370000\"\r\n' . $smsText . chr(26) .'\r\n';

 fputs($comport, $atcmd1);
 fputs($comport, $atcmd2);


 fclose($comport);

0 个答案:

没有答案