从 php 拨打 Windows 串行调制解调器
我正在尝试从 php 拨打电话号码(我在数据库中有一个客户列表,我想当我点击他们的名字时我可以用它来给他们打电话,
这是我的代码,它似乎不起作用。我可以听到电话线咔嗒声,但似乎没有拨号,也许我缺少一些需要在 atdt 之前发送的命令?
$device = "COM4";
exec("mode $device BAUD=9600 PARITY=n DATA=8 STOP=1 xon=off octs=off rts=on");
$comport = fopen($device, "r+b");
if ($comport === false) {
die ("Failed opening com port");
} else {
echo "Com Port Open";
}
stream_set_blocking($comport, 0);
$atcmd = "ATDT222222222222\r"; // dial fake number
if (fwrite($comport, $atcmd ) === false) {
die ("Failed writing to com port");
} else {
echo "Wrote $atcmd to com port";
}
sleep(10); // added fix to make program work, was closing port too soon for it to dial
fclose($comport);
I am trying to dial a phone number from php (i have a client list in a database, and thought i could use it to ring them when i click on their name
here is my code, it doesn't seem to work. I can hear the phone line click, but it doesn't seem to dial. maybe i am missing some command that needs to be sent prior to atdt?
$device = "COM4";
exec("mode $device BAUD=9600 PARITY=n DATA=8 STOP=1 xon=off octs=off rts=on");
$comport = fopen($device, "r+b");
if ($comport === false) {
die ("Failed opening com port");
} else {
echo "Com Port Open";
}
stream_set_blocking($comport, 0);
$atcmd = "ATDT222222222222\r"; // dial fake number
if (fwrite($comport, $atcmd ) === false) {
die ("Failed writing to com port");
} else {
echo "Wrote $atcmd to com port";
}
sleep(10); // added fix to make program work, was closing port too soon for it to dial
fclose($comport);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决了,愚蠢的我
所需要的只是 fclose 之前的 sleep()
它只是在实际进行任何拨号之前关闭端口
除此之外它似乎工作正常
solved, silly me
all that is needed is a sleep() before the fclose
it was just closing the port before it could actually do any dialing
apart from that it seems to work fine
尝试
Try