[Asterisk-Users] PHP and ASterisk Manager
Anton Krall
akrall-lists at intruder.com.mx
Tue Sep 6 12:16:20 MST 2005
I was able to do and if and while loops to get the block of lines I want..
Now.. Another issue.
I need to parse the line read to insert it into a table but seems Asterisk
inserts TABS or SPACES inconsistantly.. For example:
Xxx(TAB)xxx(5 spaces)xxx
Next line
Xxx(TAB)xxx(3 spaces)xxx
Im having a hard time figuring out how Asterisk Manager returns the stuff :)
Well..s o far so good...
|-----Original Message-----
|From: asterisk-users-bounces at lists.digium.com
|[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of
|Matthew Boehm
|Sent: Martes, 06 de Septiembre de 2005 01:49 p.m.
|To: Asterisk Users Mailing List - Non-Commercial Discussion
|Subject: Re: [Asterisk-Users] PHP and ASterisk Manager
|
|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 at 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
|
More information about the asterisk-users
mailing list