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