Asterisk::AMI 模块

发布于 2024-11-12 18:53:40 字数 913 浏览 4 评论 0原文

我正在学习 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

2024-11-19 18:53:40

包含:,您的脚本应该显示错误/警告。

use warnings;

如果您在脚本开头

Your script should show errors/warnings if you include:

use warnings;

at the start of your script.

梦境 2024-11-19 18:53:40

我也遇到过同样的问题
然后我发现我必须配置
/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;

血之狂魔 2024-11-19 18:53:40

您在这里缺少命令:
'$action = $astman->({...'
应该是
'$action = $astman->send_action({...'

You are missing comman here:
'$action = $astman->({...'
it should be
'$action = $astman->send_action({...'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文