Anton Krall wrote:
Guys, is anybody using PHP sockets to connect to the Manager and send
command like "show voicemail users" for example or any other?
My question is, how to parse the return info in a way that can be shown back
to the user via web (discard all the manager responses not needed)?
Use preg_match() to match the lines you want the user to see on the website.
$socket = fsockopen("localhost","5038", $errno, $errstr, 30);
if(!$socket) {
print "No socket";
exit();
}
fputs($socket, "Action: Login\r\n");
fputs($socket, "Events: Off\r\n");
fputs($socket, "UserName: bleh\r\n");
fputs($socket, "Secret: bleh\r\n\r\n");
fputs($socket, "Action: Command\r\n");
fputs($socket, "Command: show channels\r\n\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");
while(!feof($socket)) {
$buff = fgets($socket,1024);
if(preg_match("/SIP\/.*/", $buff)) {
print "I found a SIP call";
}
}
_______________________________________________
--Bandwidth and Colocation sponsored by Easynews.com --
Asterisk-Users mailing list
Asterisk-Users@lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users