[Asterisk-Users] PHP and ASterisk Manager
Christoph Eicke
cei at inmedias.it
Wed Sep 7 00:12:18 MST 2005
I looked into the source code of Asterisk to figure out how the printf()
statements were spaced. That's the power of open source, you can look under
the hood for these questions. It's easy to find, even for non-C-Gurus. Just
do a "grep" for the string that you want inside of the Asterisk source
directory and it will give you the file that the string you are looking for
is in. Then simply open the file, search for the string and look at the
printf() statement.
Christoph
On Tuesday 06 September 2005 21:16, Anton Krall wrote:
> 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
>
> _______________________________________________
> --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