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