Soporte & Consultoria

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

viernes, 9 de diciembre de 2016

AMI event catcher

<?php


$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: mypass456\r\n\r\n");
            fputs($socket, "Action: WaitEvent\r\n");
            fputs($socket, "Action: Logoff\r\n\r\n");

 while(!feof($socket)){
  $result=fread($socket,5000);

if (preg_match("/\b$argv[1]\b/i", $result,$match)){

echo $result;
}
}
}
fclose($socket);


?>

catch event  php ami.php Newchannel

runt this command php ami.php Newchannel



Array vesion



/****************************/

<?php


$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: mypass456\r\n\r\n");
            fputs($socket, "Action: WaitEvent\r\n");
            fputs($socket, "Action: Logoff\r\n\r\n");

 while(!feof($socket)){
  $result=fread($socket,5000);

if (preg_match("/\b$argv[1]\b/i", $result,$match)){

//echo $result;
$result=explode("\n",$result);
foreach($result as $key=>$value){
echo "$key : $value\n";
}

}
}
}
fclose($socket);


?>






root@asterisk-dominicana:~# php ami.php Newchannel
0 : Event: Newchannel
1 : Privilege: call,all
2 : Channel: SIP/102-0000abd1
3 : ChannelState: 0
4 : ChannelStateDesc: Down
5 : CallerIDNum: 102
6 : CallerIDName: <unknown>
7 : ConnectedLineNum: <unknown>
8 : ConnectedLineName: <unknown>
9 : Language: en
10 : AccountCode:
11 : Context: home
12 : Exten: 13052362323
13 : Priority: 1
14 : Uniqueid: 1481351003.64411
15 : Linkedid: 1481351003.64411
16 :
17 :
0 : Event: Newchannel
1 : Privilege: call,all
2 : Channel: SIP/400-0000abd2
3 : ChannelState: 0
4 : ChannelStateDesc: Down
5 : CallerIDNum: <unknown>
6 : CallerIDName: phone
7 : ConnectedLineNum: <unknown>
8 : ConnectedLineName: <unknown>
9 : Language: en
10 : AccountCode:
11 : Context: pstn
12 : Exten: s
13 : Priority: 1
14 : Uniqueid: 1481351003.64412
15 : Linkedid: 1481351003.64411
16 :
17 :

nohup php event_catch.php Newchannel >> even.txt 

No hay comentarios:

Publicar un comentario