Soporte & Consultoria

Soporte Remoto y Consultoria skype : ambiorixg12.
Nota no se brinda ningun tipo de consulta o soporte fuera del blog de forma gratuita

domingo, 1 de marzo de 2015

AMI Interface PHP EXAMPLE

<?php
$command=$_GET["cmd"];
$socket = fsockopen("127.0.0.1","5038", $errno, $errstr, 10);
      if (!$socket){
        echo "$errstr ($errno)\n";
        }else{
            fputs($socket, "Action: Login\r\n");
            fputs($socket, "UserName: admin\r\n");
            fputs($socket, "Secret: 1456\r\n\r\n");

            fputs($socket, "Action: Command\r\n");
            fputs($socket, "Command: $command\r\n\r\n");

           fputs($socket, "Action: Logoff\r\n\r\n");
           while (!feof($socket)){
               echo fgets($socket).'<br>';
            }
            fclose($socket);
            }
?>
 


 

 

http://6.11.11.22/ami_monitor.php?cmd=core%20show%20channels

 

 

Hint

Be careful to use just one Return (\r\n) after "Action" and doublereturn (\r\n\r\n) after "Command".
Example (in PHP):
fputs($socket, "Action: Command\r\n");
fputs($socket, "Command: show dialplan\r\n\r\n");

2 comentarios: