line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SMS::Send::CMTelecom; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
992
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
43
|
|
5
|
1
|
|
|
1
|
|
9
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
112
|
|
6
|
1
|
|
|
1
|
|
828
|
use HTTP::Tiny; |
|
1
|
|
|
|
|
77020
|
|
|
1
|
|
|
|
|
45
|
|
7
|
1
|
|
|
1
|
|
534
|
use SMS::API::CMTelecom; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
73
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
10
|
use base 'SMS::Send::Driver'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9110
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$SMS::Send::CMTelecom::VERSION = '0.03'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
1
|
|
|
1
|
1
|
91
|
my ($class, %args) = @_; |
15
|
1
|
|
|
|
|
4
|
my $self = \%args; |
16
|
|
|
|
|
|
|
|
17
|
1
|
50
|
|
|
|
7
|
croak '_producttoken missing' if not exists $self->{_producttoken}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$self->{_sms} = SMS::API::CMTelecom->new( |
20
|
|
|
|
|
|
|
product_token => $self->{_producttoken}, |
21
|
1
|
|
|
|
|
8
|
); |
22
|
|
|
|
|
|
|
|
23
|
1
|
50
|
|
|
|
7
|
$self->{_verbose} = 0 unless exists $self->{_verbose}; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
8
|
return bless $self, $class; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub send_sms { |
29
|
1
|
|
|
1
|
1
|
1257
|
my ($self, %args) = @_; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# remove leading + |
32
|
1
|
|
|
|
|
6
|
( my $recipient = $args{to} ) =~ s/^\+//; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $response = $self->{_sms}->send( |
35
|
|
|
|
|
|
|
message => $args{text}, |
36
|
|
|
|
|
|
|
recipients => $recipient, |
37
|
|
|
|
|
|
|
exists $args{reference} ? (reference => $args{reference}) : (), |
38
|
1
|
50
|
|
|
|
11
|
exists $args{_from} ? (sender => $args{_from}) : (), |
|
|
50
|
|
|
|
|
|
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
1
|
50
|
|
|
|
5
|
if (defined $response) { |
42
|
0
|
0
|
|
|
|
0
|
warn "send_sms succeeded: ".$response->{messages}->[0]->{parts} if $args{_verbose}; |
43
|
0
|
|
|
|
|
0
|
return 1; |
44
|
|
|
|
|
|
|
} |
45
|
1
|
50
|
|
|
|
4
|
warn "send_sms failed: ".$self->{_sms}->error_message if $args{_verbose}; |
46
|
1
|
|
|
|
|
4
|
return 0; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |