| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# Net::SMS::Clickatell . This module provides access to Clickattel SMS messaging service |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Author: Roberto Alamos Moreno |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# Copyright (c) 2004 Roberto Alamos Moreno. All rights reserved. |
|
7
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
|
8
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# Clickatell is Copyright (c) 2004 Clickatell (Pty) Ltd: Bulk SMS Gateway |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# November 2004. Antofagasta, Chile. |
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
package Net::SMS::Clickatell; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$VERSION = '0.05'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
6416
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
33
|
|
|
19
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
30
|
|
|
20
|
1
|
|
|
1
|
|
987
|
use diagnostics; |
|
|
1
|
|
|
|
|
226177
|
|
|
|
1
|
|
|
|
|
13
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
1723
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
59598
|
|
|
|
1
|
|
|
|
|
41
|
|
|
23
|
1
|
|
|
1
|
|
9
|
use URI::Escape qw(uri_escape); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
1284
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Net::SMS::Clickatell - Access to Clickatell SMS messaging service |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use Net::SMS::Clickatell; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $catell = Net::SMS::Clickatell->new( API_ID => $api_id ); |
|
34
|
|
|
|
|
|
|
$catell->auth( USER => $user, PASSWD => $passwd ); |
|
35
|
|
|
|
|
|
|
$catell->sendmsg( TO => $mobile_phone, MSG => 'Hi, I\'m using Clickatell.pm' ); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Clickatell (http://www.clickatell.com) is a commercial service that allows its users to send |
|
40
|
|
|
|
|
|
|
SMS messages to anyone in the world. This service supports many ways to send messages, for |
|
41
|
|
|
|
|
|
|
example HTTP, SMTP and SMPP, among others. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Net::SMS::Clickatell provides OO methods that allow to send SMS messages through |
|
44
|
|
|
|
|
|
|
Clickatell service. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Note that whether this software nor the author are related to Clickatell in any way. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 METHODS |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=over 4 |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item new |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Creates the Clickatell object. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Usage: |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $catell = Net::SMS::Clickatell->new( API_ID => $api_id ); |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
The complete list of arguments is: |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
API_ID : Unique number received from Clickatell when an account is created. |
|
63
|
|
|
|
|
|
|
UseSSL : Tell Clickatell module whether to use SSL or not (0 or 1). |
|
64
|
|
|
|
|
|
|
BaseURL : Default URL used to connect with Clickatell service. |
|
65
|
|
|
|
|
|
|
UserAgent : Name of the user agent you want to display to Clickatell service. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub new { |
|
70
|
0
|
|
0
|
0
|
1
|
|
my $class = shift || undef; |
|
71
|
0
|
0
|
|
|
|
|
if(!defined $class) { |
|
72
|
0
|
|
|
|
|
|
return undef; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Get arguments |
|
76
|
0
|
|
|
|
|
|
my %args = ( UseSSL => 1, |
|
77
|
|
|
|
|
|
|
UserAgent => 'Clickatell.pm/'.$Net::SMS::Clickatell::VERSION, |
|
78
|
|
|
|
|
|
|
@_ ); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Check arguments |
|
81
|
0
|
0
|
|
|
|
|
if(!exists $args{API_ID}) { |
|
82
|
|
|
|
|
|
|
# There isn't an API identification number. We can't continue |
|
83
|
0
|
|
|
|
|
|
return undef; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
0
|
0
|
|
|
|
|
if($args{UseSSL} =~ /\D/) { |
|
86
|
|
|
|
|
|
|
# UseSSL argument wasn't valid. Set it to 1 |
|
87
|
0
|
|
|
|
|
|
$args{UseSSL} = 1; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
0
|
0
|
|
|
|
|
if(!exists $args{BaseURL}) { |
|
90
|
|
|
|
|
|
|
# BaseURL argument wasn't passed. Set it to default. |
|
91
|
|
|
|
|
|
|
# Check if we have to use SSL. |
|
92
|
0
|
0
|
|
|
|
|
if(exists $args{UseSSL}) { |
|
93
|
0
|
|
|
|
|
|
$args{BaseURL} = 'https://api.clickatell.com'; |
|
94
|
|
|
|
|
|
|
} else { |
|
95
|
0
|
|
|
|
|
|
$args{BaseURL} = 'http://api.clickatell.com'; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
} else { |
|
98
|
|
|
|
|
|
|
# Set BaseURL property value. |
|
99
|
|
|
|
|
|
|
# Check if we have to use SSL. |
|
100
|
0
|
0
|
|
|
|
|
if(exists $args{UseSSL}) { |
|
101
|
0
|
|
|
|
|
|
$args{BaseURL} = 'https://'.$args{BaseURL}; |
|
102
|
|
|
|
|
|
|
} else { |
|
103
|
0
|
|
|
|
|
|
$args{BaseURL} = 'http://'.$args{BaseURL}; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
return bless { BASE_URL => $args{BaseURL}, |
|
108
|
|
|
|
|
|
|
API_ID => uri_escape($args{API_ID}), |
|
109
|
|
|
|
|
|
|
USE_SSL => $args{UseSSL}, |
|
110
|
|
|
|
|
|
|
USER_AGENT => $args{UserAgent}, |
|
111
|
|
|
|
|
|
|
SESSION_ID => 0, |
|
112
|
|
|
|
|
|
|
MSG_ID => 0, |
|
113
|
|
|
|
|
|
|
ERROR => 0,}, $class; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item auth |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Logs in Clickatell service, |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Usage: |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
$catell->auth( USER => $user, PASSWD => $passwd ); |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
where $user and $password are your credentials for Clickatell service. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This method returns 1 or 0 if we logged in or not . |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub auth { |
|
131
|
0
|
|
0
|
0
|
1
|
|
my $self = shift || undef; |
|
132
|
0
|
0
|
|
|
|
|
if(!defined $self) { |
|
133
|
0
|
|
|
|
|
|
return undef; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# Get arguments |
|
137
|
0
|
|
|
|
|
|
my %args = ( @_ ); |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# Check arguments |
|
140
|
0
|
0
|
0
|
|
|
|
if(!exists $args{USER} || !exists $args{PASSWD}) { |
|
141
|
|
|
|
|
|
|
# User or password argument wasn't set |
|
142
|
0
|
|
|
|
|
|
$self->error(1); |
|
143
|
0
|
|
|
|
|
|
return undef; |
|
144
|
|
|
|
|
|
|
} else { |
|
145
|
|
|
|
|
|
|
# Convert arguments to HTTP-compatible format |
|
146
|
0
|
|
|
|
|
|
$args{USER} = uri_escape($args{USER}); |
|
147
|
0
|
|
|
|
|
|
$args{PASSWD} = uri_escape($args{PASSWD}); |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# We have the arguments. Set session_id and msg_id to 0 |
|
151
|
0
|
|
|
|
|
|
$self->session_id(0); |
|
152
|
0
|
|
|
|
|
|
$self->msg_id(0); |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# Form Clickatell URL |
|
155
|
0
|
|
|
|
|
|
my $url = $self->{BASE_URL}.'/http/auth?user='.$args{USER}.'&password='.$args{PASSWD}.'&api_id='.$self->{API_ID}; |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# Create LWP object |
|
158
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
|
159
|
0
|
|
|
|
|
|
$ua->agent($self->{USER_AGENT}); |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Form GET message |
|
162
|
0
|
|
|
|
|
|
my $req = HTTP::Request->new(GET => $url); |
|
163
|
0
|
|
|
|
|
|
$req->header('Accept' => 'text/html'); |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# Send authentification request! |
|
166
|
0
|
|
|
|
|
|
my $res = $ua->request($req); |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# Check the response |
|
169
|
0
|
0
|
|
|
|
|
if ($res->is_success) { |
|
170
|
|
|
|
|
|
|
# HTTP transaction was succesfull |
|
171
|
|
|
|
|
|
|
# Parse response (OK: [session id]) |
|
172
|
0
|
|
|
|
|
|
my @content = split(/\:/,$res->content); |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
# Check if we logged in |
|
175
|
0
|
0
|
|
|
|
|
if($content[0] eq 'OK') { |
|
176
|
|
|
|
|
|
|
# Logged in! Store identification number and set error to 0 (no error) |
|
177
|
0
|
|
|
|
|
|
$content[1] =~ s/\s//g; |
|
178
|
0
|
|
|
|
|
|
$self->session_id($content[1]); |
|
179
|
0
|
|
|
|
|
|
$self->error(0); |
|
180
|
|
|
|
|
|
|
} else { |
|
181
|
|
|
|
|
|
|
# We didn't log in (wrong user or password) |
|
182
|
0
|
|
|
|
|
|
$self->error(2); |
|
183
|
0
|
|
|
|
|
|
return undef; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
} else { |
|
186
|
|
|
|
|
|
|
# Something is wrong |
|
187
|
0
|
|
|
|
|
|
$self->error(3); # Server error ? |
|
188
|
0
|
|
|
|
|
|
return undef; |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
return 1; |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=item sendmsg |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Sends a message trought Clickatell service. |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Usage: |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
$catell->sendmsg( TO => $mobile_phone, MSG => $msg ); |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
where $mobile_phone is the mobile phone number that you wants |
|
203
|
|
|
|
|
|
|
to sends the message (international format, no leading zeros) and |
|
204
|
|
|
|
|
|
|
$msg is the message's text. |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
This method return 1 or 0 if we successfully sent the message or not. |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=cut |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub sendmsg { |
|
211
|
0
|
|
0
|
0
|
1
|
|
my $self = shift || undef; |
|
212
|
0
|
0
|
|
|
|
|
if(!defined $self) { |
|
213
|
0
|
|
|
|
|
|
return undef; |
|
214
|
|
|
|
|
|
|
} |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
# Check if we are logged in |
|
217
|
0
|
0
|
|
|
|
|
if(!$self->session_id) { |
|
218
|
0
|
|
|
|
|
|
return undef; |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
# Get arguments |
|
222
|
0
|
|
|
|
|
|
my %args = ( @_ ); |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
# Check arguments |
|
225
|
|
|
|
|
|
|
# Check destinatary number |
|
226
|
0
|
0
|
|
|
|
|
if(!exists $args{TO}) { |
|
|
|
0
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
# There isn't a mobile number to send the message |
|
228
|
0
|
|
|
|
|
|
return undef; |
|
229
|
|
|
|
|
|
|
} elsif($args{TO} =~ /\D/) { |
|
230
|
|
|
|
|
|
|
# The argument has something that isn't a digit |
|
231
|
0
|
|
|
|
|
|
return undef; |
|
232
|
|
|
|
|
|
|
} else { |
|
233
|
|
|
|
|
|
|
# Argument OK. Convert it to HTTP-compatible |
|
234
|
0
|
|
|
|
|
|
$args{TO} = uri_escape($args{TO}); |
|
235
|
|
|
|
|
|
|
} |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
# Check the message that will be sent |
|
238
|
0
|
0
|
|
|
|
|
if(!exists $args{MSG}) { |
|
239
|
|
|
|
|
|
|
# There's no message |
|
240
|
0
|
|
|
|
|
|
return undef; |
|
241
|
|
|
|
|
|
|
} else { |
|
242
|
|
|
|
|
|
|
# Message OK. Convert it to HTTP-compatible |
|
243
|
0
|
|
|
|
|
|
$args{MSG} = uri_escape($args{MSG}); |
|
244
|
|
|
|
|
|
|
} |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
# Clickatell URL that will be used to send the message |
|
247
|
0
|
|
|
|
|
|
my $url = $self->{BASE_URL}.'/http/sendmsg?session_id='.$self->session_id().'&to='.$args{TO}.'&text='.$args{MSG}; |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
# Create LWP object |
|
250
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
|
251
|
0
|
|
|
|
|
|
$ua->agent($self->{USER_AGENT}); |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
# Prepare the message as POST variables |
|
254
|
0
|
|
|
|
|
|
my $req = HTTP::Request->new(POST => $self->{BASE_URL}.'/http/sendmsg'); |
|
255
|
0
|
|
|
|
|
|
$req->content_type('application/x-www-form-urlencoded'); |
|
256
|
0
|
|
|
|
|
|
$req->content('session_id='.$self->session_id().'&to='.$args{TO}.'&text='.$args{MSG}); |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
# Send message! |
|
259
|
0
|
|
|
|
|
|
my $res = $ua->request($req); |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
# Check if the message was successfully sent |
|
262
|
0
|
0
|
|
|
|
|
if ($res->is_success) { |
|
263
|
|
|
|
|
|
|
# The HTTP transaction was succesfull |
|
264
|
|
|
|
|
|
|
# Parse response (ID: [message_id]) |
|
265
|
0
|
|
|
|
|
|
my @content = split(/\:/,$res->content); |
|
266
|
|
|
|
|
|
|
|
|
267
|
0
|
0
|
|
|
|
|
if($content[0] eq 'ID') { |
|
268
|
|
|
|
|
|
|
# The message was successfully sent. Store message id and set error to 0 (there's no error) |
|
269
|
0
|
|
|
|
|
|
$content[1] =~ s/\s//g; |
|
270
|
0
|
|
|
|
|
|
$self->error(0); |
|
271
|
0
|
|
|
|
|
|
$self->msg_id($content[1]); |
|
272
|
|
|
|
|
|
|
} else { |
|
273
|
|
|
|
|
|
|
# The message wasn't sent :( |
|
274
|
0
|
|
|
|
|
|
$self->error(4); # The message wasn't sent |
|
275
|
0
|
|
|
|
|
|
$self->msg_id(0); # There isn't a message |
|
276
|
0
|
|
|
|
|
|
return undef; |
|
277
|
|
|
|
|
|
|
} |
|
278
|
|
|
|
|
|
|
} else { |
|
279
|
|
|
|
|
|
|
# Something is wrong with the HTTP transaction |
|
280
|
0
|
|
|
|
|
|
$self->error(3); # Server error ? |
|
281
|
0
|
|
|
|
|
|
$self->msg_id(0); # There isn't a message |
|
282
|
0
|
|
|
|
|
|
return undef; |
|
283
|
|
|
|
|
|
|
} |
|
284
|
|
|
|
|
|
|
|
|
285
|
0
|
|
|
|
|
|
return 1; |
|
286
|
|
|
|
|
|
|
} |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=item session_id |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
Set or retrieve a session identificator number. This number is returned by |
|
291
|
|
|
|
|
|
|
Clickatell service when a user logs in successfully in the service. |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
Usage: |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
$catell->session_id(); # Retrieve session identificator number |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
or |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
$catell->session_id($sid); # Set session identificator number to $sid |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=cut |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
sub session_id { |
|
304
|
0
|
|
0
|
0
|
1
|
|
my $self = shift || undef; |
|
305
|
0
|
0
|
|
|
|
|
if(!defined $self) { |
|
306
|
0
|
|
|
|
|
|
return undef; |
|
307
|
|
|
|
|
|
|
} |
|
308
|
|
|
|
|
|
|
|
|
309
|
0
|
|
0
|
|
|
|
my $ssid = shift || undef; |
|
310
|
0
|
0
|
|
|
|
|
if(!$ssid) { |
|
311
|
0
|
|
|
|
|
|
return $self->{SESSION_ID}; |
|
312
|
|
|
|
|
|
|
} else { |
|
313
|
0
|
|
|
|
|
|
$self->{SESSION_ID} = $ssid; |
|
314
|
0
|
|
|
|
|
|
return 0; |
|
315
|
|
|
|
|
|
|
} |
|
316
|
|
|
|
|
|
|
} |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=item msg_id |
|
319
|
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
Set or retrieve a message identificator number. This number is returned by |
|
321
|
|
|
|
|
|
|
Clickatell service is a message was successfully sent. |
|
322
|
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
Usage: |
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
$catell->msg_id(); # Retrieve message identificator number |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
or |
|
328
|
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
$catell->msg_id($mid); # Set message identificator number to $mid |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
=cut |
|
332
|
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
sub msg_id { |
|
334
|
0
|
|
0
|
0
|
1
|
|
my $self = shift || undef; |
|
335
|
0
|
0
|
|
|
|
|
if(!defined $self) { |
|
336
|
0
|
|
|
|
|
|
return undef; |
|
337
|
|
|
|
|
|
|
} |
|
338
|
|
|
|
|
|
|
|
|
339
|
0
|
|
0
|
|
|
|
my $msid = shift || undef; |
|
340
|
0
|
0
|
|
|
|
|
if(!$msid) { |
|
341
|
0
|
|
|
|
|
|
return $self->{MSG_ID}; |
|
342
|
|
|
|
|
|
|
} else { |
|
343
|
0
|
|
|
|
|
|
$self->{MSG_ID} = $msid; |
|
344
|
0
|
|
|
|
|
|
return 0; |
|
345
|
|
|
|
|
|
|
} |
|
346
|
|
|
|
|
|
|
} |
|
347
|
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
=item error |
|
349
|
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
Returns a code that describes the last error ocurred. |
|
351
|
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
Example: |
|
353
|
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
if(my $error = $catell->error) { |
|
355
|
|
|
|
|
|
|
if($error == 1) { |
|
356
|
|
|
|
|
|
|
die("Username or password not defined\n"); |
|
357
|
|
|
|
|
|
|
} elseif ($error == 2) { |
|
358
|
|
|
|
|
|
|
die("Username or password invalid\n"); |
|
359
|
|
|
|
|
|
|
} else { |
|
360
|
|
|
|
|
|
|
die("Unexpected fault\n"); |
|
361
|
|
|
|
|
|
|
} |
|
362
|
|
|
|
|
|
|
} |
|
363
|
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
Complete list of error codes: |
|
365
|
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
0 - No error |
|
367
|
|
|
|
|
|
|
1 - Username or password not defined |
|
368
|
|
|
|
|
|
|
2 - Username or password wrong |
|
369
|
|
|
|
|
|
|
3 - Server has problems |
|
370
|
|
|
|
|
|
|
4 - The message couldn't be sent |
|
371
|
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
=cut |
|
373
|
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
sub error { |
|
375
|
0
|
|
0
|
0
|
1
|
|
my $self = shift || undef; |
|
376
|
0
|
0
|
|
|
|
|
if(!defined $self) { |
|
377
|
0
|
|
|
|
|
|
return undef; |
|
378
|
|
|
|
|
|
|
} |
|
379
|
|
|
|
|
|
|
|
|
380
|
0
|
|
0
|
|
|
|
my $error = shift || undef; |
|
381
|
0
|
0
|
|
|
|
|
if(!defined $error) { |
|
382
|
0
|
|
|
|
|
|
return $self->{ERROR}; |
|
383
|
|
|
|
|
|
|
} else { |
|
384
|
0
|
|
|
|
|
|
$self->{ERROR} = $error; |
|
385
|
0
|
|
|
|
|
|
return 1; |
|
386
|
|
|
|
|
|
|
} |
|
387
|
|
|
|
|
|
|
} |
|
388
|
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
=back 4 |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
=head1 AUTHOR |
|
392
|
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
Roberto Alamos Moreno |
|
394
|
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
396
|
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
Copyright (c) 2004 Roberto Alamos Moreno. All rights reserved. |
|
398
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
|
399
|
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
Clickatell is Copyright (c) 2004 Clickatell (Pty) Ltd: Bulk SMS Gateway |
|
401
|
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
This software or the author aren't related to Clickatell in any way. |
|
403
|
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
=cut |
|
405
|
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
1; |