Asterisk::AMI 模块
我正在学习 Perl 中的 Asterisk::AMI 模块来连接到 asterisk。运行以下程序时,我无法连接到星号。谁能给我解决这个问题的方法?
use Asterisk::AMI;
my $astman = Asterisk::AMI->new(PeerAddr => '127.0.0.1', #Remote host address
PeerPort => '5038', #Remote host port
#AMI is available on TCP port 5038 if you enable it in manager.conf.
Username => 'admin', #Username to access the AMI
Secret => 'supersecret' #Secret used to connect to AMI
);
die "Unable to connect to asterisk" unless ($astman);
my $action = $astman->({ Action => 'Command',
Command => 'sip show peers'
});
print $action;
提前致谢。
I'm learning about Asterisk::AMI module in perl to connect to asterisk. While running the following program I can't connect to asterisk. can anyone give me solution to solve this issue?.
use Asterisk::AMI;
my $astman = Asterisk::AMI->new(PeerAddr => '127.0.0.1', #Remote host address
PeerPort => '5038', #Remote host port
#AMI is available on TCP port 5038 if you enable it in manager.conf.
Username => 'admin', #Username to access the AMI
Secret => 'supersecret' #Secret used to connect to AMI
);
die "Unable to connect to asterisk" unless ($astman);
my $action = $astman->({ Action => 'Command',
Command => 'sip show peers'
});
print $action;
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
包含:,您的脚本应该显示错误/警告。
如果您在脚本开头
Your script should show errors/warnings if you include:
at the start of your script.
我也遇到过同样的问题
然后我发现我必须配置
/etc/asterisk/manager.conf 文件中的用户
就像这个例子
http://www.voip-info.org/wiki/view /Asterisk+config+manager.conf
你就会成功;
I've been passing through the same problem
Then I discovered that I had to configure
the user in /etc/asterisk/manager.conf file
Just like this example
http://www.voip-info.org/wiki/view/Asterisk+config+manager.conf
you will get success;
您在这里缺少命令:
'$action = $astman->({...'
应该是
'$action = $astman->send_action({...'
You are missing comman here:
'$action = $astman->({...'
it should be
'$action = $astman->send_action({...'