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