我正在尝试从 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);