我正在尝试使用Http Connection连接到我的Asterisk Manager界面。这不适合我。有人可以帮帮我吗?
我需要使用php登录Asteric manager界面。 PHP文件应该在另一台服务器上。
manager.conf
[general]
enabled = yes
webenabled = yes
port = 5038
bindaddr = 0.0.0.0
displayconnects=no ;only effects 1.6+
[sameera]
secret = 123123
deny=0.0.0.0/0.0.0.0
permit=192.168.100.122/255.255.255.0
read = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate
write = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate
writetimeout = 5000
192.168.100.122是我的服务器IP地址
的login.php
<?php
$timeout = 3;
$socket = fsockopen("192.168.100.122",'12321',$errno,$errstr,$timeout);
fputs($socket,"Action: Login\r\n");
fputs($socket,"Username: sameera\r\n");
fputs($socket,"Secret: 123123\r\n\r\n");
$line="";
$response="";
while($line != "\r\n"){
$line = fgetss($socket,128);
$response .= $line;
}
echo $response;
?>
答案 0 :(得分:1)
您的端口号错误,请将12321更改为5039
$socket = fsockopen("192.168.100.122",'5039',$errno,$errstr,$timeout);
<?php
$timeout = 3;
$socket = fsockopen("127.0.0.1",'5038',$errno,$errstr,$timeout);
fputs($socket,"Action: Login\r\n");
fputs($socket,"Username: julio\r\n");
fputs($socket,"Secret: 12345\r\n\r\n");
$line="";
$response="";
while($line != "\r\n"){
$line = fgetss($socket,128);
$response .= $line;
}
echo $response;
?>
答案 1 :(得分:0)
使用phpagi / ami库,不要再重新创建
调试代码并确保防火墙允许连接。