RELOAD ASTERISK USING SOCKET PHP + AMI MANAGER


Berikut adalah cara reload asterisk menggunakan socket php + ami manager

 

<?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: myusername\r\n");
            fputs($socket, "Secret: mypassword\r\n\r\n");

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


cd /etc/asterisk/

manager.conf
[general]
displaysystemname = yes
enabled = yes
webenabled = yes
port = 5038
httptimeout = 300
bindaddr = 0.0.0.0


[myusername]
secret = mypassword
read = system,call,all,command
write = system,call,all,command

Privileges ditentukan berdasarkan command

mos-eisley*CLI> show manager commands
http.conf
enabled=yes
enablestatic=yes
bindaddr=192.168.0.195
bindport=8088
prefix=asterisk

by mustafa 

Advertisements

4 thoughts on “RELOAD ASTERISK USING SOCKET PHP + AMI MANAGER

  1. hackmyass January 23, 2013 at 7:42 pm Reply

    thanks bro!

    it worked

  2. valeiro August 2, 2013 at 6:45 pm Reply

    Great Mustafa, you are Huge 😉

  3. Ambiorix September 23, 2014 at 4:28 am Reply

    Thank you for your code it wiorks!

  4. Вадим Илларионов March 14, 2015 at 3:43 am Reply

    Thanks Mustafa! Nice work!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

shisdew

Listens until think alike

moses.spaceku@yahoo.com / voip ipbx

Hosted PBX, IP-PBX SOHO/ CALL CENTER, VOICE GATEWAY, VOICE CARD, COST EFECTIVE SOLUTIONS (LCR), GSM/CDMA GATEWAY

%d bloggers like this: