| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SMS::Send::Kannel::SMSbox; |
|
2
|
1
|
|
|
1
|
|
69235
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
30
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
30
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use base qw{SMS::Send::Driver::WebService}; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
637
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
7
|
|
|
|
|
|
|
our $PACKAGE = __PACKAGE__; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
SMS::Send::Kannel::SMSbox - SMS::Send driver for Kannel SMSbox web service |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Using L Driver API |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
SMS-Send.ini |
|
18
|
|
|
|
|
|
|
[Kannel::SMSbox] |
|
19
|
|
|
|
|
|
|
host=mykannelserver |
|
20
|
|
|
|
|
|
|
username=myuser |
|
21
|
|
|
|
|
|
|
password=mypass |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use SMS::Send; |
|
24
|
|
|
|
|
|
|
my $service = SMS::Send->new('Kannel::SMSbox'); |
|
25
|
|
|
|
|
|
|
my $success = $service->send_sms( |
|
26
|
|
|
|
|
|
|
to => '+1-800-555-1212', |
|
27
|
|
|
|
|
|
|
text => 'Hello World!', |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
SMS::Send driver for Kannel SMSbox web service. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 USAGE |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use SMS::Send::Kannel::SMSbox; |
|
37
|
|
|
|
|
|
|
my $service = SMS::Send::Kannel::SMSbox->new( |
|
38
|
|
|
|
|
|
|
username => $username, |
|
39
|
|
|
|
|
|
|
password => $password, |
|
40
|
|
|
|
|
|
|
host => $host, |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
my $success = $service->send_sms( |
|
43
|
|
|
|
|
|
|
to => '+18005551212', |
|
44
|
|
|
|
|
|
|
text => 'Hello World!', |
|
45
|
|
|
|
|
|
|
); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 METHODS |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 send_sms |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Sends the SMS message and returns 1 for success and 0 for failure or die on critical error. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub send_sms { |
|
56
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
57
|
0
|
|
|
|
|
|
my %argv = @_; |
|
58
|
0
|
0
|
|
|
|
|
my $to = $argv{"to"} or die("Error: to address required"); |
|
59
|
0
|
0
|
|
|
|
|
my $text = defined($argv{"text"}) ? $argv{"text"} : ''; |
|
60
|
0
|
|
|
|
|
|
my $url = $self->url; #isa URI |
|
61
|
0
|
|
|
|
|
|
my @form = ( |
|
62
|
|
|
|
|
|
|
username => $self->username, |
|
63
|
|
|
|
|
|
|
password => $self->password, |
|
64
|
|
|
|
|
|
|
to => $to, |
|
65
|
|
|
|
|
|
|
text => $text, |
|
66
|
|
|
|
|
|
|
); |
|
67
|
0
|
|
|
|
|
|
$url->query_form(\@form); |
|
68
|
|
|
|
|
|
|
#print "$url\n"; |
|
69
|
0
|
|
|
|
|
|
my $response = $self->ua->get($url); |
|
70
|
0
|
0
|
|
|
|
|
die(sprintf("HTTP Error: %s", $response->status_line)) unless $response->is_success; |
|
71
|
0
|
|
|
|
|
|
my $content = $response->decoded_content; |
|
72
|
0
|
|
|
|
|
|
$self->{"__content"}=$content; |
|
73
|
|
|
|
|
|
|
#use Data::Dumper qw{Dumper}; |
|
74
|
|
|
|
|
|
|
#print Dumper($content); |
|
75
|
0
|
|
|
|
|
|
my $data = $content; |
|
76
|
0
|
|
|
|
|
|
$self->{"__data"}=$data; |
|
77
|
|
|
|
|
|
|
#print Dumper($data); |
|
78
|
0
|
|
0
|
|
|
|
my $status = $data || ''; |
|
79
|
0
|
0
|
|
|
|
|
return $status =~ m/^0:/ ? 1 : 0; #0: Accepted for delivery |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 PROPERTIES |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 username |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Sets and returns the username string value |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Override in sub class |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _username_default {"myusername"}; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Override in configuration |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
[Kannel::SMSbox] |
|
95
|
|
|
|
|
|
|
username=myusername |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
#see SMS::Send::Driver::WebService->userame |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 password |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Sets and returns the password string value |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Override in sub class |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _password_default {"mypassword"}; |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Override in configuration |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
[Kannel::SMSbox] |
|
112
|
|
|
|
|
|
|
password=mypassword |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
#see SMS::Send::Driver::WebService->password |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 host |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Default: 127.0.0.1 |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Override in sub class |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub _host_default {"myhost.domain.tld"}; |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Override in configuration |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
[Kannel::SMSbox] |
|
129
|
|
|
|
|
|
|
host=myhost.domain.tld |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
#see SMS::Send::Driver::WebService->host |
|
134
|
|
|
|
|
|
|
|
|
135
|
0
|
|
|
0
|
|
|
sub _host_default {"127.0.0.1"}; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 protocol |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Default: http |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Override in sub class |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub _protocol_default {"https"}; |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Override in configuration |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
[Kannel::SMSbox] |
|
148
|
|
|
|
|
|
|
protocol=https |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
#see SMS::Send::Driver::WebService->protocol |
|
153
|
|
|
|
|
|
|
|
|
154
|
0
|
|
|
0
|
|
|
sub _protocol_default {"http"}; |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 port |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Default: 13013 |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Override in sub class |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub _port_default {443}; |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Override in configuration |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
[Kannel::SMSbox] |
|
167
|
|
|
|
|
|
|
port=443 |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
#see SMS::Send::Driver::WebService->port |
|
172
|
|
|
|
|
|
|
|
|
173
|
0
|
|
|
0
|
|
|
sub _port_default {13013}; |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 script_name |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Default: /cgi-bin/sendsms |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Override in sub class |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub _script_name_default {"/path/file"}; |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Override in configuration |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
[Kannel::SMSbox] |
|
186
|
|
|
|
|
|
|
script_name=/path/file |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
#see SMS::Send::Driver::WebService->script_name |
|
191
|
|
|
|
|
|
|
|
|
192
|
0
|
|
|
0
|
|
|
sub _script_name_default {'/cgi-bin/sendsms'}; |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 url |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Returns a L object based on above properties |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
#see SMS::Send::Driver::WebService->url |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 BUGS |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head1 SUPPORT |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 AUTHOR |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Michael R. Davis |
|
209
|
|
|
|
|
|
|
CPAN ID: MRDVT |
|
210
|
|
|
|
|
|
|
Satellite Tracking of People, LLC |
|
211
|
|
|
|
|
|
|
mdavis@stopllc.com |
|
212
|
|
|
|
|
|
|
http://www.stopllc.com/ |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
The full text of the license can be found in the LICENSE file included with this module. |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
L, L |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=cut |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
1; |