$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");
gracias por el aporte
ResponderEliminarHola, muy claro el ejemplo si quisiera saber cuando se realiza una llamada, seria con el evento "Hangup"
ResponderEliminar