line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#$Id: SOAP.pm,v 1.1 2010/11/28 15:22:42 pfarr Exp $ |
2
|
|
|
|
|
|
|
package Net::SMS::Clickatell::SOAP; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=pod |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Net::SMS::Clickatell::SOAP - SOAP interface to the Clickatell SMS service |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Pure Perl module to access the Clickatell Bulk SMS gateway |
13
|
|
|
|
|
|
|
using the SOAP protocol. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use SMS::Clickatell::SOAP; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $sms = new SMS::Clickatell::SOAP( |
18
|
|
|
|
|
|
|
connection => ( |
19
|
|
|
|
|
|
|
proxy => $PROXY_URL, |
20
|
|
|
|
|
|
|
service => $SERVICE_URL, |
21
|
|
|
|
|
|
|
verbose => $VERBOSE, |
22
|
|
|
|
|
|
|
user => $WS_USER, |
23
|
|
|
|
|
|
|
password => $WS_PASSWD, |
24
|
|
|
|
|
|
|
api_id => 123456 |
25
|
|
|
|
|
|
|
) |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 METHODS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=over |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
23058
|
use 5.008008; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
35
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
36
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
40
|
|
37
|
1
|
|
|
1
|
|
5
|
use vars qw(@ISA $VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
79
|
|
38
|
1
|
|
|
1
|
|
587
|
use SOAP::Lite; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use Carp; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
require Exporter; |
42
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
43
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
44
|
|
|
|
|
|
|
'all' => [ |
45
|
|
|
|
|
|
|
qw( |
46
|
|
|
|
|
|
|
delmsg |
47
|
|
|
|
|
|
|
errorcode |
48
|
|
|
|
|
|
|
getbalance |
49
|
|
|
|
|
|
|
getmsgcharge |
50
|
|
|
|
|
|
|
ping |
51
|
|
|
|
|
|
|
querymsg |
52
|
|
|
|
|
|
|
routecoverage |
53
|
|
|
|
|
|
|
sendmsg |
54
|
|
|
|
|
|
|
sessionid |
55
|
|
|
|
|
|
|
) |
56
|
|
|
|
|
|
|
] |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
our @EXPORT = qw( |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
use version; $VERSION = sprintf "0.%02d.%03d", q$Revision: 1.1 $ =~ /(\d+)/g; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
## Globals |
67
|
|
|
|
|
|
|
my ( $VERBOSE, ); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
############################################################################### |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item $sms = new( api_id => $api_id, user => $user, password => $password ); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Class constructor method instantiates a class object and initiates a connection |
74
|
|
|
|
|
|
|
to the Clickatell service through the auth call. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $hSMS = new SMS::Clickatell::SOAP( |
77
|
|
|
|
|
|
|
proxy => $endpoint, |
78
|
|
|
|
|
|
|
service => "${endpoint}?wsdl", |
79
|
|
|
|
|
|
|
verbose => 0 |
80
|
|
|
|
|
|
|
); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
where: |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=over |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item proxy (optional) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
SOAP connection parameter. See SOAP::Lite for further information. Defaults to |
89
|
|
|
|
|
|
|
http://api.clickatell.com/soap/webservice.php. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item service (optional) |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
SOAP connection parameter. See SOAP::Lite for further information. Defaults to |
94
|
|
|
|
|
|
|
http://api.clickatell.com/soap/webservice.php?wsdl. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item verbose |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Verbosity level for debugging. Default is verbose=>0 (only error output). |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=back |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub new { |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my ( $status, $session_id, $result, $proxy, $service, ); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my ( $class, %params ) = @_; |
109
|
|
|
|
|
|
|
$VERBOSE = $params{verbose}; # Easier and more readable as $VERBOSE |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
## Set default connection parameters if they were not passed. |
112
|
|
|
|
|
|
|
if ( exists $params{'proxy'} && defined $params{'proxy'} ) { |
113
|
|
|
|
|
|
|
$proxy = $params{'proxy'}; |
114
|
|
|
|
|
|
|
} else { |
115
|
|
|
|
|
|
|
$proxy = "http://api.clickatell.com/soap/webservice.php"; |
116
|
|
|
|
|
|
|
$params{'proxy'} = $proxy; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
if ( exists $params{'service'} && defined $params{'service'} ) { |
119
|
|
|
|
|
|
|
$service = $params{'service'}; |
120
|
|
|
|
|
|
|
} else { |
121
|
|
|
|
|
|
|
$service = $proxy . '?wsdl'; |
122
|
|
|
|
|
|
|
$params{'service'} = $service; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
## Initialize our class object, bless it and return it |
126
|
|
|
|
|
|
|
my $self = { |
127
|
|
|
|
|
|
|
_status => 0, # Status of the connection (0 or 1) |
128
|
|
|
|
|
|
|
_som => undef, # Pointer to connection object |
129
|
|
|
|
|
|
|
_last_result => undef, # Save the last result code |
130
|
|
|
|
|
|
|
_session_id => undef, # Session ID from Clickatell |
131
|
|
|
|
|
|
|
_params => \%params, # Save the passed parms in our object instance |
132
|
|
|
|
|
|
|
_verbose => $params{'verbose'}, |
133
|
|
|
|
|
|
|
}; |
134
|
|
|
|
|
|
|
bless $self, $class; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
## Connect to the AlarmPoint web server |
137
|
|
|
|
|
|
|
print "Connecting to service at $params{proxy}... " if $VERBOSE; |
138
|
|
|
|
|
|
|
my $sms = new SOAP::Lite( |
139
|
|
|
|
|
|
|
proxy => $proxy, |
140
|
|
|
|
|
|
|
service => $service, |
141
|
|
|
|
|
|
|
); |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
## If the basic connection was made then establish a session and save |
144
|
|
|
|
|
|
|
## the SOAP object for later reference |
145
|
|
|
|
|
|
|
if ($sms) { |
146
|
|
|
|
|
|
|
print "connected!\n" if $VERBOSE; |
147
|
|
|
|
|
|
|
$self->{'_som'} = $sms; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
return $self; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
############################################################################### |
154
|
|
|
|
|
|
|
## _checkResult() |
155
|
|
|
|
|
|
|
## |
156
|
|
|
|
|
|
|
## Internal function to check the status of a SOAP method call |
157
|
|
|
|
|
|
|
## |
158
|
|
|
|
|
|
|
## Parameters |
159
|
|
|
|
|
|
|
## SOM object |
160
|
|
|
|
|
|
|
## |
161
|
|
|
|
|
|
|
## Returns |
162
|
|
|
|
|
|
|
## This subroutine returns a string based on the SOAP result envelope. |
163
|
|
|
|
|
|
|
## If all went well it should return "OK". If not then it will return |
164
|
|
|
|
|
|
|
## either the faultcode (if a SOAP fault occurred) or the result |
165
|
|
|
|
|
|
|
## string if there was a method error on the server side. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub _checkResult { |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
my ( $self, $response ) = @_; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
my $VERBOSE = $self->{'_verbose'}; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
if ( $response->fault ) { |
174
|
|
|
|
|
|
|
printf STDERR "A %s fault has occurred: %s\n", $response->faultcode, |
175
|
|
|
|
|
|
|
$response->faultstring; |
176
|
|
|
|
|
|
|
return $response->fault(); |
177
|
|
|
|
|
|
|
} else { |
178
|
|
|
|
|
|
|
if ( ref( $response->result ) eq "" ) { |
179
|
|
|
|
|
|
|
printf STDERR "\tReceived response: '%s'\n", $response->result |
180
|
|
|
|
|
|
|
if $VERBOSE > 1; |
181
|
|
|
|
|
|
|
$self->{'_last_result'} = $response->result; |
182
|
|
|
|
|
|
|
return $response->result; |
183
|
|
|
|
|
|
|
} elsif ( ref( $response->result ) eq "ARRAY" ) { |
184
|
|
|
|
|
|
|
my $return = ''; |
185
|
|
|
|
|
|
|
foreach my $element ( @{ $response->result } ) { |
186
|
|
|
|
|
|
|
$return .= "$element; "; |
187
|
|
|
|
|
|
|
$self->{'_last_result'} = $return; |
188
|
|
|
|
|
|
|
return $return; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
} else { |
191
|
|
|
|
|
|
|
return "WARNING: I don't know how to handle a '" |
192
|
|
|
|
|
|
|
. ref( $response->result ) |
193
|
|
|
|
|
|
|
. "' result\n"; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
############################################################################### |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item $msg = $sms->errorCode( $code ); |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Convert a numeric error code to a text error message |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
where: |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=over |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=item $code |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
numeric error code returned by the Clickatell API |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item $msg |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
associated text error message |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=back |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=cut |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub errorcode { |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
my ( $self, $errorCode ) = @_; |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
if ( ref($self) eq 'SCALAR' ) { $errorCode = $self } |
226
|
|
|
|
|
|
|
; # Not called as an object |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
## Codes as of version 1.1.8 of the Clickatell SOAP API specification |
229
|
|
|
|
|
|
|
my %codes = ( |
230
|
|
|
|
|
|
|
'001' => 'Authentication failed', |
231
|
|
|
|
|
|
|
'002' => 'Unknown username or password', |
232
|
|
|
|
|
|
|
'003' => 'Session ID expired', |
233
|
|
|
|
|
|
|
'004' => 'Account frozen', |
234
|
|
|
|
|
|
|
'005' => 'Missing session ID', |
235
|
|
|
|
|
|
|
'007' => 'IP Lockdown violation', |
236
|
|
|
|
|
|
|
'101' => 'Invalid or missing parameters', |
237
|
|
|
|
|
|
|
'102' => 'Invalid user data header', |
238
|
|
|
|
|
|
|
'103' => 'Unknown API message ID', |
239
|
|
|
|
|
|
|
'104' => 'Unknown client message ID', |
240
|
|
|
|
|
|
|
'105' => 'Invalid destination address', |
241
|
|
|
|
|
|
|
'106' => 'Invalid source address', |
242
|
|
|
|
|
|
|
'107' => 'Empty message', |
243
|
|
|
|
|
|
|
'108' => 'Invalid or missing API ID', |
244
|
|
|
|
|
|
|
'109' => 'Missing message ID', |
245
|
|
|
|
|
|
|
'110' => 'Error with email message', |
246
|
|
|
|
|
|
|
'111' => 'Invalid protocol', |
247
|
|
|
|
|
|
|
'112' => 'Invalid message type', |
248
|
|
|
|
|
|
|
'113' => 'Maximum message parts', |
249
|
|
|
|
|
|
|
'114' => 'Cannot route message', |
250
|
|
|
|
|
|
|
'115' => 'Message expired', |
251
|
|
|
|
|
|
|
'116' => 'Invalid Unicode data', |
252
|
|
|
|
|
|
|
'120' => 'Invalid delivery time', |
253
|
|
|
|
|
|
|
'121' => 'Destination mobile number', |
254
|
|
|
|
|
|
|
'122' => 'Destination mobile opted out', |
255
|
|
|
|
|
|
|
'123' => 'Invalid Sender ID', |
256
|
|
|
|
|
|
|
'128' => 'Number delisted', |
257
|
|
|
|
|
|
|
'201' => 'Invalid batch ID', |
258
|
|
|
|
|
|
|
'202' => 'No batch template', |
259
|
|
|
|
|
|
|
'301' => 'No credit left', |
260
|
|
|
|
|
|
|
'302' => 'Max allowed credit' |
261
|
|
|
|
|
|
|
); |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
return $codes{$errorCode}; |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
############################################################################### |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=item $id = $sms->sessionId(); |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
Return the current session id |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=cut |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
sub sessionid { |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
my ($self) = @_; |
278
|
|
|
|
|
|
|
return $self->{'_session_id'}; |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
############################################################################### |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=item $resp = $sms->auth( user=>$user, password=>$password, api_id=>$api_id); |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Send credentials to Clickatell to authenticate the session. |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=over |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=item user |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
Clickatell user id |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=item password |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
Clickatell password |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=item api_id |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
Regisered API ID as assigned by Clickatell |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=back |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
The response will be: |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=over |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
=item OK: |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=item ERR: xxx |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
Error returned by the Clickatell API |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=back |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=cut |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
sub auth { |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
my ($self, %params) = @_; |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
#TODO: etter error checking of input parameters |
323
|
|
|
|
|
|
|
my $response = $self->{'_som'}->call( |
324
|
|
|
|
|
|
|
auth => SOAP::Data->name( 'user' => $params{'user'} ), |
325
|
|
|
|
|
|
|
SOAP::Data->name( 'password' => $params{'password'} ), |
326
|
|
|
|
|
|
|
SOAP::Data->name( 'api_id' => $params{'api_id'} ), |
327
|
|
|
|
|
|
|
); |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
## If the session was established successfully the response will be |
330
|
|
|
|
|
|
|
## "OK: " |
331
|
|
|
|
|
|
|
my $result = $self->_checkResult($response); |
332
|
|
|
|
|
|
|
if ( $result =~ /OK:\s+(\S+)/ ) { |
333
|
|
|
|
|
|
|
$self->{'_session_id'} = $1; # Save the session ID |
334
|
|
|
|
|
|
|
$self->{'_status'} = 1; # Mark session as active |
335
|
|
|
|
|
|
|
printf STDERR "Session ID %s has been assigned\n", $1 if $VERBOSE; |
336
|
|
|
|
|
|
|
} else { |
337
|
|
|
|
|
|
|
print STDERR "Error '$result' while establishing session\n" if $VERBOSE; |
338
|
|
|
|
|
|
|
} |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
return $result; |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
} |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
############################################################################### |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
=item $resp = $sms->ping(); |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
Send a ping to the service to keep the session alive. |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
The response will be: |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
=over |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
=item OK: |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
=item ERR: xxx |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
where xxx is a numeric error code |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
=back |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
=cut |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
sub ping { |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
my ($self) = @_; |
367
|
|
|
|
|
|
|
printf STDERR "pinging on session '%s'... ", $self->{'_session_id'} |
368
|
|
|
|
|
|
|
if $VERBOSE; |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
my $response = |
371
|
|
|
|
|
|
|
$self->{'_som'}->call( |
372
|
|
|
|
|
|
|
ping => SOAP::Data->name( 'session_id' => $self->{'_session_id'} ), ); |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
my $rc = _checkResult( $self, $response ); |
375
|
|
|
|
|
|
|
printf STDERR "%s\n", $rc if $VERBOSE; |
376
|
|
|
|
|
|
|
return $rc; |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
} |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
############################################################################### |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
=item $resp = $sms->getbalance(); |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
Query the number of credits available in the account. |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
=over |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
=item Credit: nn.nnn |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
Amount of outstanding credit balance for the account. |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
=item ERR: xxx |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
where xxx is a numeric error code |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
=back |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
=cut |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
sub getbalance { |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
my ( $self, %data ) = @_; |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
printf STDERR "getbalance %s... ", $self->{'_session_id'} if $VERBOSE; |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
my $response = |
407
|
|
|
|
|
|
|
$self->{'_som'}->call( getbalance => |
408
|
|
|
|
|
|
|
SOAP::Data->name( 'session_id' => $self->{'_session_id'} ), ); |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
my $rc = _checkResult( $self, $response ); |
411
|
|
|
|
|
|
|
printf STDERR "%s\n", $rc if $VERBOSE; |
412
|
|
|
|
|
|
|
return $rc; |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
} |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
############################################################################### |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
=item $resp = $sms->routeCoverage( msisdn => $msisdn ); |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
Chck the coverage of a network or number without sending a message. |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
where: |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
=over |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
=item msisdn |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
The network or number to be checked for coverage. |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
=back |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
The response will be: |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
=over |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
=item OK: followed by coverage information |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
Eg. OK: This prefix is currently supported. Messages sent to this prefix will be routed. Charge: 0.33 |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
=item ERR: xxx |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
where xxx is a numeric error code |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
=back |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
=cut |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
sub routecoverage { |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
my ( $self, %data ) = @_; |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
printf STDERR "routeCoverage %s... ", $data{'msisdn'} if $VERBOSE; |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
my $response = $self->{'_som'}->call( |
455
|
|
|
|
|
|
|
routeCoverage => |
456
|
|
|
|
|
|
|
SOAP::Data->name( 'session_id' => $self->{'_session_id'} ), |
457
|
|
|
|
|
|
|
SOAP::Data->name( 'msisdn' => $data{'msisdn'} ), |
458
|
|
|
|
|
|
|
); |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
my $rc = _checkResult( $self, $response ); |
461
|
|
|
|
|
|
|
printf STDERR "%s\n", $rc if $VERBOSE; |
462
|
|
|
|
|
|
|
return $rc; |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
} |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
############################################################################### |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
=item $resp = $hSMS->querymsg( apiMsgId => $apiMsgId ); |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
=item $resp = $hSMS->querymsg( cliMsgId => $cliMsgId ); |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
=over |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
=item apiMsgId |
475
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
API message id (apiMsgId) returned by the gateway after a message was sent. |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
=item cliMsgId |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
client message ID (cliMsgId) you used on submission of the message. |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
=back |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
the response will be: |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
=over |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
=item ID: followed by message status |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
eg. ID: 18e8221e5aa50cfad72376e08f40388a Status: 001; |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
Status codes are defined by the Clickatell API. |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
=item ERR: |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
where xxx is a numeric error code |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=back |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
=cut |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
sub querymsg { |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
my $idType = undef, my $matched = 0; |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
my ( $self, %data ) = @_; |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
foreach my $key ( 'apiMsgId', 'cliMsgId' ) { |
509
|
|
|
|
|
|
|
if ( exists $data{$key} && defined $data{$key} ) { |
510
|
|
|
|
|
|
|
$matched = 1; |
511
|
|
|
|
|
|
|
$idType = $key; |
512
|
|
|
|
|
|
|
} |
513
|
|
|
|
|
|
|
} |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
if ( !$matched ) { |
516
|
|
|
|
|
|
|
return "ERROR: Either 'apiMsgId' or 'cliMsgId' must be defined"; |
517
|
|
|
|
|
|
|
} |
518
|
|
|
|
|
|
|
printf STDERR "querymsg %s=%s... ", $idType, $data{$idType} if $VERBOSE; |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
my $response = $self->{'_som'}->call( |
521
|
|
|
|
|
|
|
querymsg => SOAP::Data->name( 'session_id' => $self->{'_session_id'} ), |
522
|
|
|
|
|
|
|
SOAP::Data->name( $idType => $data{$idType} ), |
523
|
|
|
|
|
|
|
); |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
my $rc = _checkResult( $self, $response ); |
526
|
|
|
|
|
|
|
printf STDERR "%s\n", $rc if $VERBOSE; |
527
|
|
|
|
|
|
|
return $rc; |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
} |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
############################################################################### |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
=item $resp = $sms->querymsg( apiMsgId => $apiMsgId ); |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
Query the status of a message. |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
=over |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
=item apiMsgId |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
API message id (apiMsgId) returned by the gateway after a message was sent. |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
=back |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
the respones will be: |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=over |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
=item apiMsgId: followed by message status |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
eg. apiMsgId: 18e8221e5aa50cfad72376e08f40388a charge: 0.33 status: 004; |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
Status codes are defined by the Clickatell API. |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
=item ERR: |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
where xxx is a numeric error code |
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
=back |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
=cut |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
sub getmsgcharge { |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
my ( $self, %data ) = @_; |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
if ( !exists $data{'apiMsgId'} || !defined $data{'apiMsgId'} ) { |
568
|
|
|
|
|
|
|
return "ERROR: Either 'apiMsgId' or 'cliMsgId' must be defined"; |
569
|
|
|
|
|
|
|
} |
570
|
|
|
|
|
|
|
printf STDERR "querymsg %s=%s... ", 'apiMsgId', $data{'apiMsgId'} |
571
|
|
|
|
|
|
|
if $VERBOSE; |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
my $response = $self->{'_som'}->call( |
574
|
|
|
|
|
|
|
getmsgcharge => |
575
|
|
|
|
|
|
|
SOAP::Data->name( 'session_id' => $self->{'_session_id'} ), |
576
|
|
|
|
|
|
|
SOAP::Data->name( 'apiMsgId' => $data{'apiMsgId'} ), |
577
|
|
|
|
|
|
|
); |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
my $rc = _checkResult( $self, $response ); |
580
|
|
|
|
|
|
|
printf STDERR "%s\n", $rc if $VERBOSE; |
581
|
|
|
|
|
|
|
return $rc; |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
} |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
############################################################################### |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
=item $resp = $hSMS->delmsg( apiMsgId => $apiMsgId ); |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
=item $resp = $hSMS->delmsg( cliMsgId => $cliMsgId ); |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
Delete a previously sent message. |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
=over |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
=item apiMsgId |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
API message id (apiMsgId) returned by the gateway after a message was sent. |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
=item cliMsgId |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
client message ID (cliMsgId) you used on submission of the message. |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
=back |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
the response will be: |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
=over |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
=item ID: followed by message status |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
eg. ID: 18e8221e5aa50cfad72376e08f40388a Status: 001; |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
Status codes are defined by the Clickatell API. |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
=item ERR: |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
where xxx is a numeric error code |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
=back |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
=cut |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
sub delmsg { |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
my $idType = undef, my $matched = 0; |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
my ( $self, %data ) = @_; |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
foreach my $key ( 'apiMsgId', 'cliMsgId' ) { |
630
|
|
|
|
|
|
|
if ( exists $data{$key} && defined $data{$key} ) { |
631
|
|
|
|
|
|
|
$matched = 1; |
632
|
|
|
|
|
|
|
$idType = $key; |
633
|
|
|
|
|
|
|
} |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
if ( !$matched ) { |
637
|
|
|
|
|
|
|
return "ERROR: Either 'apiMsgId' or 'cliMsgId' must be defined"; |
638
|
|
|
|
|
|
|
} |
639
|
|
|
|
|
|
|
printf STDERR "delmsg %s=%s... ", $idType, $data{$idType} if $VERBOSE; |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
my $response = $self->{'_som'}->call( |
642
|
|
|
|
|
|
|
delmsg => SOAP::Data->name( 'session_id' => $self->{'_session_id'} ), |
643
|
|
|
|
|
|
|
SOAP::Data->name( $idType => $data{$idType} ), |
644
|
|
|
|
|
|
|
); |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
my $rc = _checkResult( $self, $response ); |
647
|
|
|
|
|
|
|
printf STDERR "%s\n", $rc if $VERBOSE; |
648
|
|
|
|
|
|
|
return $rc; |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
} |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
############################################################################### |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
=item $resp = $hSMS->sendmsg(to => '19991234567', text => 'Hello there...'); |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
=item $resp = $hSMS->sendmsg(to => @phoneNumbers, text => 'Hello there...'); |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
Chck the coverage of a network or number without sending a message. If item_user |
659
|
|
|
|
|
|
|
is supplied, then preexisting session authentication (if any) will be ignored |
660
|
|
|
|
|
|
|
and the item_user, item_pasword and api_id values will be used to authenticate |
661
|
|
|
|
|
|
|
this call. This allows you to send a message even if the existing session has |
662
|
|
|
|
|
|
|
dropped for any reason. |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
=over |
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
=item to (required) |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
A phone number or list of phone numbers to recieve the messsage |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
=item text (required) |
671
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
The text of the message to be sent |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
=item api_id (not implemented yet) |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
=item user (not implemented yet) |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
=item password (not implemented yet) |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
=item from (not implemented yet) |
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
=item concat (not implemented yet) |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
=item deliv_ack (not implemented yet) |
685
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
=item callback (not implemented yet) |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
=item deliv_time (not implemented yet) |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
=item max_credits (not implemented yet) |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
=item req_feat (not implemented yet) |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
=item queue (not implemented yet) |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
=item escalate (not implemented yet) |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
=item mo (not implemented yet) |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
=item cliMsgId (not implemented yet) |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
=item unicode (not implemented yet) |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
=item msg_type (not implemented yet) |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
=item udh (not implemented yet) |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
=item data (not implemented yet) |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
=item validity (not implemented yet) |
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
=back |
713
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
The response will be: |
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
=over |
717
|
|
|
|
|
|
|
|
718
|
|
|
|
|
|
|
=item ID: followed by message id |
719
|
|
|
|
|
|
|
|
720
|
|
|
|
|
|
|
eg. ID: 18e8221e5aa50cfad72376e08f40388a; |
721
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
Status codes are defined by the Clickatell API. |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
=item ERR: xxx |
725
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
where xxx is a numeric error code |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
e.g. ERR: 105, Invalid Destination Address; |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
=back |
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
=cut |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
#TODO Add more than the basic parameters to sendmsg |
735
|
|
|
|
|
|
|
sub sendmsg { |
736
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
my ( $authText, $authData, @dest ); |
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
my ( $self, %data ) = @_; |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
## Figure out what authentication scheme is to be used |
742
|
|
|
|
|
|
|
if ( defined $data{'item user'} |
743
|
|
|
|
|
|
|
&& exists $data{'item user'} |
744
|
|
|
|
|
|
|
&& length( $data{'item user'} ) > 0 ) |
745
|
|
|
|
|
|
|
{ |
746
|
|
|
|
|
|
|
$authText = 'as user ' . $data{'item user'}; |
747
|
|
|
|
|
|
|
$authData = ( |
748
|
|
|
|
|
|
|
SOAP::Data->name( 'api_id' => $data{'api_id'} ), |
749
|
|
|
|
|
|
|
SOAP::Data->name( 'item user' => $data{'item user'} ), |
750
|
|
|
|
|
|
|
SOAP::Data->name( 'item password' => $data{'item password'} ) |
751
|
|
|
|
|
|
|
); |
752
|
|
|
|
|
|
|
} else { |
753
|
|
|
|
|
|
|
$authText = 'on session ' . $self->{'_session_id'}; |
754
|
|
|
|
|
|
|
$authData = SOAP::Data->name( 'session_id' => $self->{'_session_id'} ); |
755
|
|
|
|
|
|
|
} |
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
## Verify that the destination number(s) are in an array |
758
|
|
|
|
|
|
|
if ( ref( $data{'to'} ) eq 'ARRAY' ) { |
759
|
|
|
|
|
|
|
@dest = $data{'to'}; |
760
|
|
|
|
|
|
|
} else { |
761
|
|
|
|
|
|
|
push( @dest, $data{'to'} ); |
762
|
|
|
|
|
|
|
} |
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
printf STDERR "sendmsg to %s %s... ", $data{'to'}, $authText if $VERBOSE; |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
my $response = $self->{'_som'}->call( |
767
|
|
|
|
|
|
|
sendmsg => $authData, |
768
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
# SOAP::Data->name( 'session_id' => $self->{'_session_id'} ), |
770
|
|
|
|
|
|
|
# SOAP::Data->name( 'api_id' => $data{'api_id'} ), |
771
|
|
|
|
|
|
|
# SOAP::Data->name( 'item user' => $data{'item user'} ), |
772
|
|
|
|
|
|
|
# SOAP::Data->name( 'item password' => $data{'item password'} ), |
773
|
|
|
|
|
|
|
SOAP::Data->name( 'to' => @dest ), |
774
|
|
|
|
|
|
|
SOAP::Data->name( 'from' => $data{'from'} ), |
775
|
|
|
|
|
|
|
SOAP::Data->name( 'text' => $data{'text'} ), |
776
|
|
|
|
|
|
|
SOAP::Data->name( 'concat' => $data{'concat'} ), |
777
|
|
|
|
|
|
|
SOAP::Data->name( 'deliv_ack' => $data{'deliv_ack'} ), |
778
|
|
|
|
|
|
|
SOAP::Data->name( 'callback' => $data{'callback'} ), |
779
|
|
|
|
|
|
|
SOAP::Data->name( 'deliv_time' => $data{'deliv_time'} ), |
780
|
|
|
|
|
|
|
SOAP::Data->name( 'max_credits' => $data{'max_credits'} ), |
781
|
|
|
|
|
|
|
SOAP::Data->name( 'req_feat' => $data{'req_feat'} ), |
782
|
|
|
|
|
|
|
SOAP::Data->name( 'queue' => $data{'queue'} ), |
783
|
|
|
|
|
|
|
SOAP::Data->name( 'escalate' => $data{'escalate'} ), |
784
|
|
|
|
|
|
|
SOAP::Data->name( 'mo' => $data{'mo'} ), |
785
|
|
|
|
|
|
|
SOAP::Data->name( 'cliMsgId' => $data{'cliMsgId'} ), |
786
|
|
|
|
|
|
|
SOAP::Data->name( 'unicode' => $data{'unicode'} ), |
787
|
|
|
|
|
|
|
SOAP::Data->name( 'msg_type' => $data{'msg_type'} ), |
788
|
|
|
|
|
|
|
SOAP::Data->name( 'udh' => $data{'udh'} ), |
789
|
|
|
|
|
|
|
SOAP::Data->name( 'data' => $data{'data'} ), |
790
|
|
|
|
|
|
|
SOAP::Data->name( 'validity' => $data{'validity'} ), |
791
|
|
|
|
|
|
|
); |
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
my $rc = _checkResult( $self, $response ); |
794
|
|
|
|
|
|
|
printf STDERR "%s\n", $rc if $VERBOSE; |
795
|
|
|
|
|
|
|
return $rc; |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
} |
798
|
|
|
|
|
|
|
|
799
|
|
|
|
|
|
|
############################################################################### |
800
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
=item $resp = $hSMS->si_push(to => '19991234567', si_text => 'Check this out', si_url = 'http://www.perl.org'); |
802
|
|
|
|
|
|
|
|
803
|
|
|
|
|
|
|
WAP Push Service Indication (SI) is a WAP address embedded within the header of |
804
|
|
|
|
|
|
|
a specially formatted SMS. This is displayed as an alert message to the user, |
805
|
|
|
|
|
|
|
and gives the user the option of connecting directly to a particular URL via |
806
|
|
|
|
|
|
|
the handsets WAP browser (if supported). This command enables you to send a WAP |
807
|
|
|
|
|
|
|
Push Service Indication. |
808
|
|
|
|
|
|
|
|
809
|
|
|
|
|
|
|
=over |
810
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
=item to (required) |
812
|
|
|
|
|
|
|
|
813
|
|
|
|
|
|
|
A phone number or list of phone numbers to recieve the messsage |
814
|
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
=item si_id (required) |
816
|
|
|
|
|
|
|
|
817
|
|
|
|
|
|
|
Unique ID for each message |
818
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
=item si_url (required) |
820
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
The URL used to access the service |
822
|
|
|
|
|
|
|
|
823
|
|
|
|
|
|
|
=item si_text (required) |
824
|
|
|
|
|
|
|
|
825
|
|
|
|
|
|
|
The text of the message to be sent |
826
|
|
|
|
|
|
|
|
827
|
|
|
|
|
|
|
=item si_created (not implemented yet) |
828
|
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
=item si_expires (not implemented yet) |
830
|
|
|
|
|
|
|
|
831
|
|
|
|
|
|
|
=item si_action (not implemented yet) |
832
|
|
|
|
|
|
|
|
833
|
|
|
|
|
|
|
=item from (not implemented yet) |
834
|
|
|
|
|
|
|
|
835
|
|
|
|
|
|
|
=item concat (not implemented yet) |
836
|
|
|
|
|
|
|
|
837
|
|
|
|
|
|
|
=item deliv_ack (not implemented yet) |
838
|
|
|
|
|
|
|
|
839
|
|
|
|
|
|
|
=item callback (not implemented yet) |
840
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
=item deliv_time (not implemented yet) |
842
|
|
|
|
|
|
|
|
843
|
|
|
|
|
|
|
=item max_credits (not implemented yet) |
844
|
|
|
|
|
|
|
|
845
|
|
|
|
|
|
|
=item req_feat (not implemented yet) |
846
|
|
|
|
|
|
|
|
847
|
|
|
|
|
|
|
=item queue (not implemented yet) |
848
|
|
|
|
|
|
|
|
849
|
|
|
|
|
|
|
=item escalate (not implemented yet) |
850
|
|
|
|
|
|
|
|
851
|
|
|
|
|
|
|
=item mo (not implemented yet) |
852
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
=item cliMsgId (not implemented yet) |
854
|
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
=item validity (not implemented yet) |
856
|
|
|
|
|
|
|
|
857
|
|
|
|
|
|
|
=back |
858
|
|
|
|
|
|
|
|
859
|
|
|
|
|
|
|
The response will be: |
860
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
=over |
862
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
=item ID: xxx TO: xxx |
864
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
eg. ID: ID: 18e8221e5aa50cfad72376e08f40388a TO: 99991234567; |
866
|
|
|
|
|
|
|
|
867
|
|
|
|
|
|
|
Status codes are defined by the Clickatell API. |
868
|
|
|
|
|
|
|
|
869
|
|
|
|
|
|
|
=item ERR: xxx |
870
|
|
|
|
|
|
|
|
871
|
|
|
|
|
|
|
where xxx is a numeric error code |
872
|
|
|
|
|
|
|
|
873
|
|
|
|
|
|
|
e.g. ERR: 105, Invalid Destination Address; |
874
|
|
|
|
|
|
|
|
875
|
|
|
|
|
|
|
=back |
876
|
|
|
|
|
|
|
|
877
|
|
|
|
|
|
|
=cut |
878
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
#TODO Add more than the basic parameters |
880
|
|
|
|
|
|
|
#TODO Allow user/password/api_id authentication |
881
|
|
|
|
|
|
|
sub si_push { |
882
|
|
|
|
|
|
|
|
883
|
|
|
|
|
|
|
my ( $authText, $authData, @dest ); |
884
|
|
|
|
|
|
|
|
885
|
|
|
|
|
|
|
my ( $self, %data ) = @_; |
886
|
|
|
|
|
|
|
|
887
|
|
|
|
|
|
|
## Verify that the destination number(s) are in an array |
888
|
|
|
|
|
|
|
if ( ref( $data{'to'} ) eq 'ARRAY' ) { |
889
|
|
|
|
|
|
|
@dest = $data{'to'}; |
890
|
|
|
|
|
|
|
} else { |
891
|
|
|
|
|
|
|
push( @dest, $data{'to'} ); |
892
|
|
|
|
|
|
|
} |
893
|
|
|
|
|
|
|
|
894
|
|
|
|
|
|
|
printf STDERR "sendmsg to %s %s... ", $data{'to'}, $authText if $VERBOSE; |
895
|
|
|
|
|
|
|
|
896
|
|
|
|
|
|
|
my $response = $self->{'_som'}->call( |
897
|
|
|
|
|
|
|
sendmsg => |
898
|
|
|
|
|
|
|
SOAP::Data->name( 'session_id' => $self->{'_session_id'} ), |
899
|
|
|
|
|
|
|
SOAP::Data->name( 'to' => @dest ), |
900
|
|
|
|
|
|
|
SOAP::Data->name( 'from' => $data{'from'} ), |
901
|
|
|
|
|
|
|
SOAP::Data->name( 'si_id' => $data{'si_id'} ), |
902
|
|
|
|
|
|
|
SOAP::Data->name( 'si_text' => $data{'si_text'} ), |
903
|
|
|
|
|
|
|
SOAP::Data->name( 'si_url' => $data{'si_url'} ), |
904
|
|
|
|
|
|
|
# SOAP::Data->name( 'si_created' => $data{'si_created'} ), |
905
|
|
|
|
|
|
|
# SOAP::Data->name( 'si_expires' => $data{'si_expires'} ), |
906
|
|
|
|
|
|
|
# SOAP::Data->name( 'si_action' => $data{'si_action'} ), |
907
|
|
|
|
|
|
|
# SOAP::Data->name( 'concat' => $data{'concat'} ), |
908
|
|
|
|
|
|
|
# SOAP::Data->name( 'deliv_ack' => $data{'deliv_ack'} ), |
909
|
|
|
|
|
|
|
# SOAP::Data->name( 'callback' => $data{'callback'} ), |
910
|
|
|
|
|
|
|
# SOAP::Data->name( 'deliv_time' => $data{'deliv_time'} ), |
911
|
|
|
|
|
|
|
# SOAP::Data->name( 'max_credits' => $data{'max_credits'} ), |
912
|
|
|
|
|
|
|
# SOAP::Data->name( 'req_feat' => $data{'req_feat'} ), |
913
|
|
|
|
|
|
|
# SOAP::Data->name( 'queue' => $data{'queue'} ), |
914
|
|
|
|
|
|
|
# SOAP::Data->name( 'escalate' => $data{'escalate'} ), |
915
|
|
|
|
|
|
|
# SOAP::Data->name( 'mo' => $data{'mo'} ), |
916
|
|
|
|
|
|
|
# SOAP::Data->name( 'cliMsgId' => $data{'cliMsgId'} ), |
917
|
|
|
|
|
|
|
# SOAP::Data->name( 'validity' => $data{'validity'} ), |
918
|
|
|
|
|
|
|
); |
919
|
|
|
|
|
|
|
|
920
|
|
|
|
|
|
|
my $rc = _checkResult( $self, $response ); |
921
|
|
|
|
|
|
|
printf STDERR "%s\n", $rc if $VERBOSE; |
922
|
|
|
|
|
|
|
return $rc; |
923
|
|
|
|
|
|
|
|
924
|
|
|
|
|
|
|
} |
925
|
|
|
|
|
|
|
|
926
|
|
|
|
|
|
|
############################################################################### |
927
|
|
|
|
|
|
|
## End of package |
928
|
|
|
|
|
|
|
############################################################################### |
929
|
|
|
|
|
|
|
|
930
|
|
|
|
|
|
|
1; |
931
|
|
|
|
|
|
|
|
932
|
|
|
|
|
|
|
__END__ |