如何在PHP中使用加密狗发送短信 [英] How to send sms using dongle in php

查看:122
本文介绍了如何在PHP中使用加密狗发送短信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友,

我正在编写以下代码,用于通过加密狗在php中发送短信但它不起作用他们给com端口设置error.how我可以设置窗口中的端口设置短信通过在窗口操作系统上的php加密狗。

代码:

hi friend,
I am writing following code for send sms via dongle in php but it is not work propery they give com port set error.how can i set port in window to set sms via dongle in php on window OS.
Code:

<?php


require("php_serial.class.php");


$serial = new phpSerial;

// First we must specify the device. This works on both linux and windows (if
// your linux serial device is /dev/ttyS0 for COM1, etc)
$serial->deviceSet("COM13");


// We can change the baud rate, parity, length, stop bits, flow control
$serial->confBaudRate(9600);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");

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



// To write into
$serial->sendMessage("AT+CMGF=1\n\r"); 
$serial->sendMessage("AT+cmgs=\"+919428784012\"\n\r");
$serial->sendMessage("Hi, This is the sms that I sent to you using PHP script with serial Port communication with my phone as serial device!! GN - VKSALIAN \n\r");
$serial->sendMessage(chr(26));

//wait for modem to send message
sleep(7);


// Or to read from
$read = $serial->readPort();
echo $read;
// If you want to change the configuration, the device must be closed
$serial->deviceClose();

?>





结果错误:



Result Error:

Warning: Specified serial port is not valid in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 141

Warning: Unable to set the baud rate : the device is either not set or opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 234

Warning: Unable to set parity : the device is either not set or opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 288

Warning: Unable to set length of a character : the device is either not set or opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 336

Warning: Unable to set the length of a stop bit : the device is either not set or opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 377

Warning: Unable to set flow control mode : the device is either not set or opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 422

Warning: The device must be set before to be open in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 167

Warning: Device must be opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 608

Warning: Device must be opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 608

Warning: Device must be opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 608

Warning: Device must be opened in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 608

Warning: Device must be opened to read it in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\laywer-new\php_serial.class.php on line 522

推荐答案

serial = new phpSerial;

// 首先我们必须指定设备。这适用于linux和windows(如果
// 你的linux串行设备是/ dev COM1的/ ttyS0等)
serial = new phpSerial; // First we must specify the device. This works on both linux and windows (if // your linux serial device is /dev/ttyS0 for COM1, etc)


serial-> deviceSet( COM13);


// 我们可以更改波特率,奇偶校验,长度,停止位,流量控制
serial->deviceSet("COM13"); // We can change the baud rate, parity, length, stop bits, flow control


serial-> confBaudRate(9600);
serial->confBaudRate(9600);


这篇关于如何在PHP中使用加密狗发送短信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆