line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package VoIPms; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
53074
|
use 5.024001; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
28
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
352
|
use URI::Escape; |
|
1
|
|
|
|
|
1195
|
|
|
1
|
|
|
|
|
53
|
|
8
|
1
|
|
|
1
|
|
621
|
use WWW::Mechanize; |
|
1
|
|
|
|
|
122400
|
|
|
1
|
|
|
|
|
35
|
|
9
|
1
|
|
|
1
|
|
604
|
use JSON::XS; |
|
1
|
|
|
|
|
4070
|
|
|
1
|
|
|
|
|
246
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
0
|
|
|
0
|
0
|
|
my $type = shift; |
13
|
0
|
|
|
|
|
|
my %params = @_; |
14
|
0
|
0
|
0
|
|
|
|
if (!defined $params{api_username} || !defined $params{api_password}) { |
15
|
0
|
|
|
|
|
|
die "'new' requires your API username and password as the first and second argument"; |
16
|
|
|
|
|
|
|
} |
17
|
0
|
0
|
|
|
|
|
if (!defined $params{mech}) { |
18
|
0
|
|
|
|
|
|
$params{mech} = WWW::Mechanize->new(autocheck => 1, cookie_jar => {}, agent => 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; MDDRJS; rv:11.0) like Gecko'); |
19
|
|
|
|
|
|
|
} |
20
|
0
|
|
|
|
|
|
my $self = { api_username => "$params{api_username}", api_password => "$params{api_password}", mechanize => $params{mech}, location => 'https://voip.ms/api/v1/rest.php' }; |
21
|
0
|
|
|
|
|
|
bless $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub response { |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
27
|
0
|
|
|
|
|
|
my %params = @_; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $get = $self->{location} . |
30
|
|
|
|
|
|
|
'?api_username=' . uri_escape($self->{api_username}) . |
31
|
0
|
|
|
|
|
|
'&api_password=' . uri_escape($self->{api_password}); |
32
|
0
|
|
|
|
|
|
foreach my $key (keys(%params)) { |
33
|
0
|
|
|
|
|
|
$get .= '&' . $key . '=' . uri_escape($params{$key}); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $response = $self->{mechanize}->get($get)->content; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $json = JSON::XS->new; |
39
|
0
|
|
|
|
|
|
return $json->decode($response); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
our @EXPORT = qw( new response ); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |