| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SMS::Send::Iletimerkezi; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
52038
|
use 5.006; |
|
|
1
|
|
|
|
|
3
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
17
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
28
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
50
|
|
|
7
|
1
|
|
|
1
|
|
465
|
use XML::Writer; |
|
|
1
|
|
|
|
|
12578
|
|
|
|
1
|
|
|
|
|
25
|
|
|
8
|
1
|
|
|
1
|
|
573
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
44916
|
|
|
|
1
|
|
|
|
|
35
|
|
|
9
|
1
|
|
|
1
|
|
449
|
use Digest::SHA qw(hmac_sha256_hex); |
|
|
1
|
|
|
|
|
2848
|
|
|
|
1
|
|
|
|
|
100
|
|
|
10
|
1
|
|
|
1
|
|
7
|
use parent qw(SMS::Send::Driver); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
13
|
|
|
|
|
|
|
=encoding utf-8 |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
SMS::Send::Iletimerkezi - SMS::Send driver for iletimerkezi.com |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 VERSION |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Version 0.01 |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Quick summary of what the module does. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use SMS::Send; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# create new sender object with iletimerkezi driver |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $sender = SMS::Send->new('Iletimerkezi', |
|
37
|
|
|
|
|
|
|
_api_key => '', |
|
38
|
|
|
|
|
|
|
_api_secret => '', |
|
39
|
|
|
|
|
|
|
_sender => 'ILT MRKZ', |
|
40
|
|
|
|
|
|
|
_encoding => 'utf8', |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
# Send a message to me |
|
43
|
|
|
|
|
|
|
my $sent = $sender->send_sms( |
|
44
|
|
|
|
|
|
|
text => 'Hello from Perl', |
|
45
|
|
|
|
|
|
|
to => '+905321112233', |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
# Success? |
|
48
|
|
|
|
|
|
|
if ( $sent ) { |
|
49
|
|
|
|
|
|
|
print "Sent test message\n"; |
|
50
|
|
|
|
|
|
|
} else { |
|
51
|
|
|
|
|
|
|
print "Failed to send test message\n"; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 new |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
The C constructor takes three parameters, which should be passed |
|
57
|
|
|
|
|
|
|
through from the L constructor. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
_api_key and _api_secret can be found in your account / settings / api |
|
60
|
|
|
|
|
|
|
_encoding: one of gsm0338|gsm0338-tr|utf8 or can be left blank to use account default |
|
61
|
|
|
|
|
|
|
_sender: the alpha-numeric sender name you want to send message with |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub new { |
|
67
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
68
|
0
|
|
|
|
|
|
my %params = @_; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# check required parameters |
|
71
|
0
|
|
|
|
|
|
for my $param (qw ( _api_key _sender _api_secret _encoding )) { |
|
72
|
0
|
0
|
|
|
|
|
exists $params{$param} |
|
73
|
|
|
|
|
|
|
or croak ($class . "->new requires $param parameter"); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my $self = \%params; |
|
77
|
0
|
|
|
|
|
|
bless $self, $class; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return $self; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub create_sms_xml { |
|
84
|
0
|
|
|
0
|
0
|
|
my ($api_key, $api_secret, $encoding, $sender, $message, $recipients) = @_; |
|
85
|
0
|
|
|
|
|
|
my $sec_digest = hmac_sha256_hex($api_key, $api_secret); |
|
86
|
0
|
|
|
|
|
|
my $output; |
|
87
|
0
|
|
|
|
|
|
my $writer = new XML::Writer(OUTPUT => \$output, DATA_INDENT => 2); |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
$writer->xmlDecl('UTF-8'); |
|
90
|
0
|
|
|
|
|
|
$writer->startTag("request"); |
|
91
|
0
|
|
|
|
|
|
$writer->startTag("authentication"); |
|
92
|
0
|
|
|
|
|
|
$writer->dataElement('key', $api_key); |
|
93
|
0
|
|
|
|
|
|
$writer->dataElement('hash', $sec_digest); |
|
94
|
0
|
|
|
|
|
|
$writer->endTag('authentication'); |
|
95
|
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
$writer->startTag("order"); |
|
97
|
0
|
|
|
|
|
|
$writer->dataElement('sender', $sender); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# configure encoding if given any |
|
100
|
0
|
0
|
|
|
|
|
if ($encoding =~ m/^(gsm0338|gsm0338-tr|utf8)$/ig){ |
|
101
|
0
|
|
|
|
|
|
$writer->dataElement('encoding', $encoding); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
$writer->startTag("message"); |
|
105
|
0
|
|
|
|
|
|
$writer->dataElement('text', $message); |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
$writer->startTag("receipents"); |
|
108
|
0
|
|
|
|
|
|
$writer->dataElement('number', $recipients); |
|
109
|
0
|
|
|
|
|
|
$writer->endTag("receipents"); |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
$writer->endTag('message'); |
|
112
|
0
|
|
|
|
|
|
$writer->endTag('order'); |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
$writer->endTag("request"); |
|
115
|
0
|
|
|
|
|
|
$writer->end(); |
|
116
|
|
|
|
|
|
|
# print $output; |
|
117
|
0
|
|
|
|
|
|
return $output; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub send_sms { |
|
121
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
122
|
0
|
|
|
|
|
|
my %params = @_; |
|
123
|
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
my $message = delete $params{text}; |
|
125
|
0
|
|
|
|
|
|
my $recipient = delete $params{to}; |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
my $api = LWP::UserAgent->new( |
|
129
|
|
|
|
|
|
|
ssl_opts => { verify_hostname => 1, }, |
|
130
|
|
|
|
|
|
|
agent => 'Sms-Send-Iletimerkezi/'. $VERSION, |
|
131
|
|
|
|
|
|
|
); |
|
132
|
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
my $url = 'https://api.iletimerkezi.com/v1/send-sms'; |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
my $post_xml = create_sms_xml( |
|
136
|
|
|
|
|
|
|
$self->{_api_key}, |
|
137
|
|
|
|
|
|
|
$self->{_api_secret}, |
|
138
|
|
|
|
|
|
|
$self->{_encoding}, |
|
139
|
|
|
|
|
|
|
$self->{_sender}, |
|
140
|
0
|
|
|
|
|
|
$message, |
|
141
|
|
|
|
|
|
|
$recipient |
|
142
|
|
|
|
|
|
|
); |
|
143
|
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
my $response = $api->post($url, |
|
145
|
|
|
|
|
|
|
Content => $post_xml, |
|
146
|
|
|
|
|
|
|
'Content-type' => 'application/xml', |
|
147
|
|
|
|
|
|
|
); |
|
148
|
|
|
|
|
|
|
|
|
149
|
0
|
0
|
|
|
|
|
if ($response->is_success) { |
|
150
|
0
|
|
|
|
|
|
return 1; |
|
151
|
|
|
|
|
|
|
} else { |
|
152
|
0
|
|
|
|
|
|
croak $response->status_line; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
croak("Can't send sms: $response->{code} $response->{message}"); |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 AUTHOR |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Engin Dumlu, C<< >> |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 BUGS |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
166
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
167
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 SUPPORT |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
perldoc SMS::Send::Iletimerkezi |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
You can also look for information at: |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=over 4 |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
L |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
L |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
L |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item * Search CPAN |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
L |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=back |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Copyright 2018 Engin Dumlu. |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify |
|
210
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
|
211
|
|
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or |
|
212
|
|
|
|
|
|
|
(at your option) any later version. |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
|
215
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
216
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
217
|
|
|
|
|
|
|
GNU General Public License for more details. |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
|
220
|
|
|
|
|
|
|
along with this program. If not, see L. |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=cut |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
1; # End of SMS::Send::Iletimerkezi |