我需要从PHP网页发送(可能会收到)一些数据到本地软件。
该软件可以通过UDP端口1987接收和发送数据。
有办法吗? javascript activeX或flash库或其他东西
软件= VOIP SoftPhone
PHP网页= CRM
我想要的只是拨打一个按钮,如果可能的话,接收电话的长度。
答案 0 :(得分:1)
基本上用PHP读取UDP套接字需要类似:
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_bind($sock, $local, $port) or die('Could not bind to address');
while(1) {
echo socket_read($sock,1024);
}
socket_close($sock);
发送:
$frame = array(
array(1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1),
array(1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1),
array(1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,1),
array(1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,1),
array(1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,1),
array(1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,1),
array(1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1),
array(1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1)
);
send_frame($frame, 1500);
/**
* Sends 18x8 MCUF-UDP packet to target host.
*
* see also:
* wiki.blinkenarea.org/index.php/MicroControllerUnitFrame
*
* @param array $frame 18x8 '0' or '1'
* @param int $delay delay in msec
* @param string $host target host
* @param int $port target port (udp)
*/
function send_frame($frame, $delay, $host="192.168.0.23", $port=2323) {
$header = "\x23\x54\x26\x66\x00\x08\x00\x12\x00\x01\x00\xff";
$buf = $header;
for ($i=0;$i<8;$i++) {
for ($j=0;$j<18;$j++) {
if ($frame[$i][$j]) {
$buf.="\xff";
} else {
$buf.="\x00";
}
}
}
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_sendto($socket, $buf, strlen($buf), 0, $host, $port);
socket_close($socket);
usleep($delay*1000);
}