line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::SMS::Massenversand; |
2
|
2
|
|
|
2
|
|
55690
|
use warnings; |
|
2
|
|
|
|
|
21
|
|
|
2
|
|
|
|
|
72
|
|
3
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
74
|
|
4
|
2
|
|
|
2
|
|
12
|
use base "Class::Accessor::Fast"; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
1876
|
|
5
|
2
|
|
|
2
|
|
16597
|
use URI; |
|
2
|
|
|
|
|
21857
|
|
|
2
|
|
|
|
|
71
|
|
6
|
2
|
|
|
2
|
|
2312
|
use URI::QueryParam; |
|
2
|
|
|
|
|
1797
|
|
|
2
|
|
|
|
|
56
|
|
7
|
2
|
|
|
2
|
|
2627
|
use LWP::UserAgent; |
|
2
|
|
|
|
|
148464
|
|
|
2
|
|
|
|
|
1436
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(user test password msg_count error id)); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Net::SMS::Massenversand - Send SMS via Massenversand.de |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Version 0.03 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Net::SMS::Massenversand; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $sms = Net::SMS::Massenversand->new(); |
29
|
|
|
|
|
|
|
$sms->user('someuserid'); |
30
|
|
|
|
|
|
|
$sms->password('somepassword'); |
31
|
|
|
|
|
|
|
$sms->send( |
32
|
|
|
|
|
|
|
type => "sms", |
33
|
|
|
|
|
|
|
message => "Your SMS text", |
34
|
|
|
|
|
|
|
sender => 'Your Name', |
35
|
|
|
|
|
|
|
recipient => '00123456789' |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
my $limit = $sms->limit; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 METHODS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 new |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Create a new object. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 user |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Sets the user id of your Massenversand.de account |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 password |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Sets the password of your Massenversand.de account |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub new { |
59
|
1
|
|
|
1
|
1
|
13
|
my $class = shift; |
60
|
1
|
|
|
|
|
5
|
return bless( {}, $class ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 limit |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This method returns the credit which is left at your account. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Sets L in case of an error. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub limit { |
72
|
1
|
|
|
1
|
1
|
1734
|
my $self = shift; |
73
|
1
|
|
|
|
|
7
|
$self->_clear_object; |
74
|
1
|
|
|
|
|
11
|
my $response = $self->_get_response( getLimit => 1 ); |
75
|
1
|
50
|
|
|
|
97
|
if ( $response->is_success ) { |
76
|
1
|
|
|
|
|
14
|
my $c = $response->content; |
77
|
1
|
|
|
|
|
32
|
return $c; |
78
|
|
|
|
|
|
|
} else { |
79
|
0
|
|
|
|
|
0
|
die $response->status_line; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 send |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Sends the actual message. It is called with a hash which includes the necessary |
86
|
|
|
|
|
|
|
information. This method expects a latin1 encoded string as message. Available parameters are: |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=over |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item id |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Defaults to C<< $sms->user >> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item pw |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Defaults to C<< $sms->password >> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item receiver |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Set the phone number of the receiver (international format starting with "00") |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item sender |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
11 alphanumerical or 16 numerical characters allowed. Allowed characters: a-z, A-Z and 0-9 |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item message |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
The actual message you want to send. Mind that the maximum length of a sms is 160. If you |
109
|
|
|
|
|
|
|
want to send more than 160 characters specify C. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item msgtype |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Specify the type of your sms message. Avaiable types are |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item t: text SMS |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item f: flash SMS |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item b: blink SMS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item c: longer-than-160-character SMS |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=back |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Defaults to C. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=back |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
After sending a sms you can access the sms-id which has been set by Massenversand.de |
132
|
|
|
|
|
|
|
by calling L<< $sms->id >> and the number of messages your message was split into |
133
|
|
|
|
|
|
|
L<< $sms->msg_count >>. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
There are three Massenversand.de servers specified. If one fails the next one |
136
|
|
|
|
|
|
|
is used. The timeout for a request is set to 15 seconds. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Returns 1 on success or 0 and sets L in case of an error. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub send { |
144
|
1
|
|
|
1
|
1
|
1375
|
my $self = shift(@_); |
145
|
1
|
|
|
|
|
6
|
my %param = @_; |
146
|
1
|
|
|
|
|
5
|
$self->_clear_object; |
147
|
|
|
|
|
|
|
|
148
|
1
|
|
|
|
|
7
|
$param{message} = $param{message}; |
149
|
|
|
|
|
|
|
|
150
|
1
|
|
|
|
|
6
|
my $response = $self->_get_response( |
151
|
|
|
|
|
|
|
receiver => $param{receiver}, |
152
|
|
|
|
|
|
|
sender => $param{sender}, |
153
|
|
|
|
|
|
|
msg => $param{message}, |
154
|
|
|
|
|
|
|
msgtype => 'c', |
155
|
|
|
|
|
|
|
getID => 1, |
156
|
|
|
|
|
|
|
countMsg => 1, |
157
|
|
|
|
|
|
|
getStatus => 1 |
158
|
|
|
|
|
|
|
); |
159
|
1
|
50
|
|
|
|
84
|
if ( $response->is_success ) { |
160
|
1
|
|
|
|
|
23
|
my $c = $response->content; |
161
|
1
|
50
|
|
|
|
19
|
if ( $c =~ /OK \((\d+), (\d+) .*\)/ ) { |
162
|
0
|
|
|
|
|
0
|
$self->id($1); |
163
|
0
|
|
|
|
|
0
|
$self->msg_count($2); |
164
|
0
|
|
|
|
|
0
|
return 1; |
165
|
|
|
|
|
|
|
} else { |
166
|
1
|
|
|
|
|
7
|
$self->error($self->_parse_error($c)); |
167
|
1
|
|
|
|
|
121
|
return 0; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
} else { |
170
|
0
|
|
|
|
|
0
|
die( $response->status_line ); |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub _get_response { |
175
|
2
|
|
|
2
|
|
5
|
my $self = shift; |
176
|
2
|
|
|
|
|
12
|
my %param = @_; |
177
|
2
|
|
|
|
|
4
|
my $response; |
178
|
2
|
|
|
|
|
7
|
for ( 1 .. 3 ) { |
179
|
2
|
|
|
|
|
27
|
my $url = |
180
|
|
|
|
|
|
|
new URI( 'https://gate' . $_ . '.goyyamobile.com/sms/sendsms.asp' ); |
181
|
2
|
|
|
|
|
11096
|
$url->query_form_hash( |
182
|
|
|
|
|
|
|
id => $self->user, |
183
|
|
|
|
|
|
|
pw => $self->password, |
184
|
|
|
|
|
|
|
test => scalar $self->test, |
185
|
|
|
|
|
|
|
%param |
186
|
|
|
|
|
|
|
); |
187
|
2
|
|
|
|
|
651
|
my $ua = new LWP::UserAgent; |
188
|
2
|
|
|
|
|
3701
|
$ua->timeout(15); |
189
|
2
|
|
|
|
|
172
|
$response = $ua->get($url); |
190
|
2
|
50
|
|
|
|
896983
|
return $response if ( $response->is_success ); |
191
|
|
|
|
|
|
|
} |
192
|
0
|
|
|
|
|
0
|
return $response; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub _parse_error { |
196
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
197
|
1
|
|
|
|
|
3
|
my $c = shift; |
198
|
1
|
|
|
|
|
5
|
$self->_clear_object; |
199
|
1
|
|
|
|
|
103
|
$self->error($c); |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub _clear_object { |
203
|
3
|
|
|
3
|
|
7
|
my $self = shift; |
204
|
3
|
|
|
|
|
15
|
$self->id(""); |
205
|
3
|
|
|
|
|
30
|
$self->msg_count(""); |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 TODO |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=over |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=item Add support for all the sms types like flash sms. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=item MMS support |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=back |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 AUTHOR |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
Manuel Laux, C<< >>, |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Moritz Onken, C<< >> |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 BUGS |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
227
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
228
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 SUPPORT |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
perldoc Net::SMS::Massenversand |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
You can also look for information at: |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=over 4 |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
L |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
L |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=item * CPAN Ratings |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
L |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=item * Search CPAN |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
L |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=back |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
Copyright 2008 netCubed GbR, all rights reserved. |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
267
|
|
|
|
|
|
|
under the same terms as Perl itself. |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=cut |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
1; # End of Net::SMS::Massenversand |