我正在尝试使用 Asterisk::AMI 包,但一个简单的例子不起作用
#!/usr/bin/perl -w
# ami_test.pl
use strict;
use diagnostics;
use Asterisk::AMI;
// use default 127.0.0.1 5038
my $astman = Asterisk::AMI->new(
Username => 'manager',
Secret => 'secret'
);
die "Unable to connect to Asterisk" unless ($astman);
my $response = $astman->({
Action => 'Command',
Command => 'sip show peers'
});
print $response->{'Response'};
总是我得到一个错误:
Not a CODE reference at ami_test.pl line 17 (#1)
(F) Perl was trying to evaluate a reference to a code value (that is, a
subroutine), but found a reference to something else instead. You can
use the ref() function to find out what kind of ref it really was. See
also perlref.
Uncaught exception from user code:
Not a CODE reference at ami_test.pl line 17.
at ami_test.pl line 17
编辑
文档看错了,我试过了
my $response = $astman->action({
Action => 'Command',
Command => 'sip show peers'
});
并且工作正常