line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SMS::Send::TW::ShareSMS; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
20767
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
79
|
|
5
|
1
|
|
|
1
|
|
963
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
79181
|
|
|
1
|
|
|
|
|
27
|
|
6
|
1
|
|
|
1
|
|
8
|
use base 'SMS::Send::Driver'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
825
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
319
|
use vars qw{$VERSION}; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
9
|
|
|
|
|
|
|
BEGIN { |
10
|
1
|
|
|
1
|
|
218
|
$VERSION = '0.02'; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Preloaded methods go here. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
0
|
|
|
0
|
1
|
|
my ($class, %params) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
foreach(qw/username password language region/) { |
21
|
0
|
0
|
|
|
|
|
Carp::croak("No $_ specified") unless(defined $params{"_$_"}); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my $self = bless { %params }, $class; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub send_sms { |
30
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
31
|
0
|
|
|
|
|
|
my %params = @_; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Get the message and destination |
34
|
0
|
|
|
|
|
|
my $message = $self->_MESSAGE( delete $params{text} ); |
35
|
0
|
|
|
|
|
|
my $recipient = $self->_TO( delete $params{to} ); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# foreach(qw/to text/) { |
38
|
|
|
|
|
|
|
# Carp::croak("No $_ specified") unless(defined $params{"$_"}); |
39
|
|
|
|
|
|
|
# } |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new( |
42
|
|
|
|
|
|
|
agent => __PACKAGE__." v. $VERSION", |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $response = $ua->post('http://www.sharesms.com/api/SendSMS.php', |
47
|
|
|
|
|
|
|
[ CID => $self->{"_username"}, |
48
|
|
|
|
|
|
|
CPW => $self->{"_password"}, |
49
|
|
|
|
|
|
|
L => $self->{"_language"}, |
50
|
|
|
|
|
|
|
N => $recipient, |
51
|
|
|
|
|
|
|
M => $message, |
52
|
|
|
|
|
|
|
W => $self->{"_region"}, ]); |
53
|
0
|
|
|
|
|
|
return $response->content; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _MESSAGE { |
57
|
1
|
|
|
1
|
|
847
|
use bytes; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
4
|
|
58
|
0
|
0
|
|
0
|
|
|
my $class = ref $_[0] ? ref shift : shift; |
59
|
0
|
|
|
|
|
|
my $message = shift; |
60
|
0
|
0
|
|
|
|
|
unless ( length($message) <= 160 ) { |
61
|
0
|
|
|
|
|
|
Carp::croak("Message length limit is 160 characters"); |
62
|
|
|
|
|
|
|
} |
63
|
0
|
|
|
|
|
|
return $message; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub _TO { |
67
|
0
|
0
|
|
0
|
|
|
my $class = ref $_[0] ? ref shift : shift; |
68
|
0
|
|
|
|
|
|
my $to = shift; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# International numbers need their + removed |
71
|
0
|
|
|
|
|
|
$to =~ y/0123456789//cd; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return $to; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
__END__ |