line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::SMS::VoipBuster; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
40585
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
5
|
1
|
|
|
1
|
|
1140
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
125082
|
|
|
1
|
|
|
|
|
41
|
|
6
|
1
|
|
|
1
|
|
529
|
use XML::XPath; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use XML::XPath::XMLParser; |
8
|
|
|
|
|
|
|
use Carp; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
|
|
|
|
|
|
my $class = shift; |
14
|
|
|
|
|
|
|
my $user = shift; |
15
|
|
|
|
|
|
|
my $password = shift; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
croak("Please insert an user.") unless ($user); |
18
|
|
|
|
|
|
|
croak("Please insert an password.") unless ($password); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $self = bless { |
21
|
|
|
|
|
|
|
'user' => $user, |
22
|
|
|
|
|
|
|
'pass' => $password |
23
|
|
|
|
|
|
|
}, $class; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub send { |
29
|
|
|
|
|
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
my $msg = shift; |
31
|
|
|
|
|
|
|
my $to = shift; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
croak("Please insert an message.") unless ($msg); |
34
|
|
|
|
|
|
|
croak("Please insert number to destination") unless($to); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
37
|
|
|
|
|
|
|
#$ua->timeout(10); |
38
|
|
|
|
|
|
|
#$ua->env_proxy; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $send_url = $ua->get("https://www.voipbuster.com/myaccount/sendsms.php?username=$self->{'user'}&password=$self->{'pass'}&from=$self->{'user'}&to=$to&text=$msg"); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $result = $send_url->content; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$result =~ s/^(?:\s+)(.*)(?:\s+)$/$1/gm; # Thanks Manuel Silva ;) |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $xp = XML::XPath->new( 'xml' => $result ); |
47
|
|
|
|
|
|
|
my $nodeset = $xp->find('//result'); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $check; |
50
|
|
|
|
|
|
|
foreach my $node ($nodeset->get_nodelist) { |
51
|
|
|
|
|
|
|
$check = XML::XPath::XMLParser::as_string($node); |
52
|
|
|
|
|
|
|
$check =~ s/<[^>]*>//gs; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
if ($check) { |
55
|
|
|
|
|
|
|
return $self->{'success'} = 1; |
56
|
|
|
|
|
|
|
} else { |
57
|
|
|
|
|
|
|
my $error = { |
58
|
|
|
|
|
|
|
'error' => $send_url->status_line, |
59
|
|
|
|
|
|
|
'is_error' => '1', |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
return $self->{'error'} = $error; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub extra { |
67
|
|
|
|
|
|
|
my $self = shift; |
68
|
|
|
|
|
|
|
my $extra = "To my Mom. Maria Luisa Mesquista (1954 - 2007)"; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
return $self->{'extra'} = $extra; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
__END__ |