line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SMS::Send::NANP::TextPower; |
2
|
1
|
|
|
1
|
|
49240
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
4
|
1
|
|
|
1
|
|
397
|
use SMS::Send::Driver::WebService 0.06; #uat function, keep_alive=0 |
|
1
|
|
|
|
|
74540
|
|
|
1
|
|
|
|
|
27
|
|
5
|
1
|
|
|
1
|
|
7
|
use parent qw{SMS::Send::Driver::WebService}; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
6
|
1
|
|
|
1
|
|
705
|
use XML::Simple qw{XMLin}; |
|
1
|
|
|
|
|
6482
|
|
|
1
|
|
|
|
|
6
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
9
|
|
|
|
|
|
|
our $PACKAGE = __PACKAGE__; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
SMS::Send::NANP::TextPower - SMS::Send driver for TextPower WebService |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Using L Driver API |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
SMS-Send.ini |
20
|
|
|
|
|
|
|
[NANP::TextPower] |
21
|
|
|
|
|
|
|
username=myuser |
22
|
|
|
|
|
|
|
password=mypass |
23
|
|
|
|
|
|
|
campaign=MTMO |
24
|
|
|
|
|
|
|
queue=1 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use SMS::Send; |
27
|
|
|
|
|
|
|
my $service = SMS::Send->new('NANP::TextPower'); |
28
|
|
|
|
|
|
|
my $success = $service->send_sms( |
29
|
|
|
|
|
|
|
to => '+1-800-555-1212', |
30
|
|
|
|
|
|
|
text => 'Hello World!', |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This package provides an L driver against the SMS web service at TextPower L. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 USAGE |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Direct Object Usage |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
use SMS::Send::NANP::TextPower; |
42
|
|
|
|
|
|
|
my $service = SMS::Send::NANP::TextPower->new( |
43
|
|
|
|
|
|
|
username => $username, |
44
|
|
|
|
|
|
|
password => $password, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
my $success = $service->send_sms( |
47
|
|
|
|
|
|
|
to => '+18005551212', |
48
|
|
|
|
|
|
|
text => 'Hello World!', |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Subclass Usage |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
package SMS::Send::My::Driver; |
54
|
|
|
|
|
|
|
use base qw{SMS::Send::NANP::TextPower}; |
55
|
|
|
|
|
|
|
sub _username_default {return "myusername"}; |
56
|
|
|
|
|
|
|
sub _password_default {return "mypassword"}; |
57
|
|
|
|
|
|
|
sub _campaign_default {return "mycampaign"}; |
58
|
|
|
|
|
|
|
sub _queue_default {return "1"}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
use SMS::Send; |
61
|
|
|
|
|
|
|
my $service = SMS::Send->new('My::Driver'); |
62
|
|
|
|
|
|
|
my $success = $service->send_sms(to => '+18005551212', text => 'Hello World!'); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 METHODS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 send_sms |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Sends the SMS message and returns 1 for success and 0 for failure or die on critical error. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub send_sms { |
73
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
74
|
0
|
|
|
|
|
0
|
my %argv = @_; |
75
|
0
|
0
|
|
|
|
0
|
my $to = $argv{"to"} or die("Error: to address required"); |
76
|
0
|
0
|
|
|
|
0
|
my $text = defined($argv{"text"}) ? $argv{"text"} : ''; |
77
|
0
|
|
|
|
|
0
|
my @form = ( |
78
|
|
|
|
|
|
|
UID => $self->username, |
79
|
|
|
|
|
|
|
PWD => $self->password, |
80
|
|
|
|
|
|
|
Campaign => $self->campaign, |
81
|
|
|
|
|
|
|
CellNumber => $to, |
82
|
|
|
|
|
|
|
msg => $text, |
83
|
|
|
|
|
|
|
); |
84
|
0
|
0
|
|
|
|
0
|
push @form, Queue => 'y' if $self->queue; |
85
|
0
|
|
|
|
|
0
|
my $url = $self->url; |
86
|
0
|
|
|
|
|
0
|
my $response = $self->uat->post_form($url, \@form); #isa HASH from HTTP::Tiny |
87
|
0
|
0
|
|
|
|
0
|
die(sprintf("HTTP Error: %s %s", $response->{'status'}, $response->{'reason'})) unless $response->{'success'}; |
88
|
0
|
|
|
|
|
0
|
my $content = $response->{'content'}; |
89
|
0
|
|
|
|
|
0
|
my $data = XMLin($content); |
90
|
0
|
|
|
|
|
0
|
$self->{"__data"} = $data; |
91
|
0
|
|
0
|
|
|
0
|
my $status = $data->{"MessageStatus"}->{"SendResult"}->{"Status"} || ''; |
92
|
0
|
0
|
0
|
|
|
0
|
return ($status eq 'Sent' or ($self->queue and $status eq 'Queued')) ? 1 : 0; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 PROPERTIES |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 username |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Sets and returns the username string value (passed to the web service as UID) |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
#see SMS::Send::Driver::WebService->username |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 password |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Sets and returns the password string value (passed to the web service as PWD) |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
#see SMS::Send::Driver::WebService->password |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 campaign |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Sets and returns the campaign string value (passed to the web service as Campaign) |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Default: MTMO |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub campaign { |
122
|
2
|
|
|
2
|
1
|
3335
|
my $self=shift; |
123
|
2
|
50
|
|
|
|
7
|
$self->{"campaign"}=shift if @_; |
124
|
2
|
50
|
|
|
|
6
|
$self->{"campaign"}=$self->cfg_property("campaign", $self->_campaign_default) unless defined $self->{"campaign"}; |
125
|
2
|
|
|
|
|
7
|
return $self->{"campaign"}; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
0
|
|
|
sub _campaign_default {"MTMO"}; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 queue |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Sets and returns the queue boolean value (passed to the web service as Queue=y when true omitted when false) |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Default: "" (false) |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub queue { |
139
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
140
|
0
|
0
|
|
|
|
|
$self->{"queue"}=shift if @_; |
141
|
0
|
0
|
|
|
|
|
$self->{"queue"}=$self->cfg_property("queue", $self->_queue_default) unless defined $self->{"queue"}; |
142
|
0
|
|
|
|
|
|
return $self->{"queue"}; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
0
|
|
|
sub _queue_default {""}; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 url |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Sets and returns the url for the web service. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Default: https://secure.textpower.com/TPIServices/Sender.aspx |
152
|
|
|
|
|
|
|
Old Default: http://www.textpower.com/TPIServices/Sender.aspx |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
#see SMS::Send::Driver::WebService->url |
157
|
|
|
|
|
|
|
|
158
|
0
|
|
|
0
|
|
|
sub _url_default {'https://secure.textpower.com/TPIServices/Sender.aspx'}; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 BUGS |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Please log on RT and send an email to the author. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 SUPPORT |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
DavisNetworks.com supports all Perl applications including this package. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 AUTHOR |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Michael R. Davis |
171
|
|
|
|
|
|
|
CPAN ID: MRDVT |
172
|
|
|
|
|
|
|
Satellite Tracking of People, LLC |
173
|
|
|
|
|
|
|
mdavis@stopllc.com |
174
|
|
|
|
|
|
|
http://www.stopllc.com/ |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 COPYRIGHT |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
The full text of the license can be found in the LICENSE file included with this module. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 SEE ALSO |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
L |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=cut |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
1; |