[asterisk-users] Need some PHP/AMI guidance please

Pat Collins drdialtone at optonline.net
Fri Mar 28 13:49:05 CDT 2014


Hello all,

I've got some PHP code that opens an AMI socket and does a ConfBridgeList
for a specific bridge (8888).

This all works just fine but I need to filter the information displayed to
only CallerIDName so I can see a complete list of names of participants.

After days of googling and playing with it, I'm no closer than I was when I
started.

I'm not at all married to a table.  A simple list of names is fine...

Any help is much appreciated!

Pertinent code:

<?php

$ami = fsockopen("127.0.0.1", 5038, $errno, $errstr);

 

if (!$ami) {

echo "ERROR: $errno - $errstr<br />\n";

} else {

 

    fwrite($ami, "Action: Login\r\nUsername: someuser\r\nSecret:
somesecret\r\nEvents: off\r\n\r\n");

 

    fwrite($ami, "Action: ConfbridgeList\r\nConference: 8888\r\n\r\n");

     sleep(1);

 

    $record = fread($ami,1024);

    $record = explode("\r\n", $record);

    echo "<META HTTP-EQUIV=Refresh CONTENT=\"20\">";

    echo "<table border=\"1\" style='color: black;'>";

 

 

    foreach($record as $value){

        if(!strlen(stristr($value,'Asterisk'))>0

        && !strlen(stristr($value,'Response'))>0

        && !strlen(stristr($value,'Message'))>0

        && !strlen(stristr($value,'Event'))>0

        && strlen(strpos($value,' '))>0)

        php_table($value);;

    }

 

    echo "</table>";

 

    fclose($ami);

    }

 

 

function php_table($value){

        $row1 = true;

        $value = explode("  ", $value);

        foreach($value as $field){

            if($row1){

                echo "<tr><td>".$field."</td>";

                $row1 = false;

            }

            else{

                echo "<td>".$field."</td></tr>";

 

                $row1 = true;

 

            }

        }

}

 

?>

 

I think the "explode" is where I should be looking but I'm very new to PHP

Thank you!

Pat...

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20140328/30b26666/attachment.html>


More information about the asterisk-users mailing list