A PHP class for Asterisk Manager Interface.
This class is modified from voip-info.org.
This class provide following functions:
-
Login()
-
Logout()
-
Query($query)
- $query : Command string to query. e.g.
Action: SIPpeers\r\n\r\n
- $query : Command string to query. e.g.
-
Reload()
-
GetUsers()
-
AddUser($user, $type, $dir)
-
$user : Username to create
-
$type : User type (
webrtc
orsip
) -
$dir : Path to
users.conf
-
-
AddExtension($user, $dir)
- $user : Username to create
- $dir : Path to
extensions.conf
-
GetError()
include 'php-ami-class';
$conn = new AstMan;
$conn -> amiHost = 'AMI_HOST_IP_HERE';
$conn -> amiPort = 'AMI_PORT_HERE';
$conn -> amiUsername = 'AMI_USERNAME_HERE';
$conn -> amiPassword = 'AMI_PASSWORD_HERE';
//and do something else
include 'php-ami-class.php';
$conn = new AstMan;
$conn -> amiHost = '192.168.1.7';
$conn -> amiPort = '5038';
$conn -> amiUsername = 'admin';
$conn -> amiPassword = 'admin';
if ($conn -> Login()) {
$conn -> Reload();
$conn -> Logout();
return true;
}else{
echo $conn -> getError();
return false;
}
include 'php-ami-class.php';
$user = '5566';
$type = 'webrtc';
$user_dir = './conf/users'; // Path to users.conf
$ext_dir = './conf/extensions'; // Path to extensions.conf
$conn = new AstMan;
$conn -> amiHost = '192.168.1.7';
$conn -> Login();
$conn -> AddUser($user,$type, $user_dir);
$conn -> AddExtension($user, $ext_dir);
$conn -> Reload(); // Don't forget to reload Asterisk after creating user.
$conn -> Logout();
This software is licensed under GNU v2.
Please read LICENSE for information.