| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Domain::Register::DomainShare; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
Domain::Register::DomainShare - an interface to Dot TK's DomainShare API |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=cut |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# use the library |
|
13
|
|
|
|
|
|
|
use Domain::Register::DomainShare; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# create a new client for DomainShare |
|
16
|
|
|
|
|
|
|
my $client = Domain::Register::DomainShare->new(); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# ping DomainShare server |
|
19
|
|
|
|
|
|
|
my $result = $client->ping(); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
... |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# check domain availability |
|
24
|
|
|
|
|
|
|
my $result = $client->availability_check({ |
|
25
|
|
|
|
|
|
|
email => 'domainshare@example.tk', |
|
26
|
|
|
|
|
|
|
password => 'password', |
|
27
|
|
|
|
|
|
|
domainname => 'testdomain1.tk' |
|
28
|
|
|
|
|
|
|
}); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Dot TK's DomainShare API service lets developers design computer programs and |
|
35
|
|
|
|
|
|
|
online applications that interact directly with the Dot TK registration system |
|
36
|
|
|
|
|
|
|
for FREE domain name registration services. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
That basically means that Dot TK allows developers to register free domain names |
|
39
|
|
|
|
|
|
|
with the .TK extension from their applications. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
For more information and a list of available functions, please review the technical |
|
42
|
|
|
|
|
|
|
documentation available via http://domainshare.tk. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
An object of this class represents a potential dialogue with Dot TK's servers, |
|
48
|
|
|
|
|
|
|
and as such needs correct log in credentials to do anything useful. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Standard usage is to create an object and perform an arbitrary number of |
|
51
|
|
|
|
|
|
|
transactions with the remote server. There is a ping transaction which does not |
|
52
|
|
|
|
|
|
|
require parameters, that should be used to test if a connection is still possible. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
No state is saved by the remote server between transactions, so it is not |
|
55
|
|
|
|
|
|
|
necessary to log on or log off separately, as long as valid credentials are |
|
56
|
|
|
|
|
|
|
supplied. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
A full list of available functions is available via the technical documentation |
|
59
|
|
|
|
|
|
|
available via http://domainshare.tk. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 MULTIVALUE PARAMETERS |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Although most calls require unique values for the given parameters, some of them |
|
65
|
|
|
|
|
|
|
should or could be multivalue. An example multivalue parameter is nameserver. |
|
66
|
|
|
|
|
|
|
When registering a domain with specifying nameservers, you need to pass at least |
|
67
|
|
|
|
|
|
|
two nameservers. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# register domain |
|
70
|
|
|
|
|
|
|
my $result = $client->register({ |
|
71
|
|
|
|
|
|
|
email => 'domainshare@example.tk', |
|
72
|
|
|
|
|
|
|
password => 'password', |
|
73
|
|
|
|
|
|
|
domainname => 'testdomain1.tk', |
|
74
|
|
|
|
|
|
|
nameserver => ['ns1.example.tk', 'ns2.example.tk' ] |
|
75
|
|
|
|
|
|
|
}); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
As you see, the multivalue parameter can simply be specified by an array reference. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 RETURN VALUES |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Any call to a function will return an array where first element is status code. |
|
83
|
|
|
|
|
|
|
The status code will be set to 1 upon success, 0 upon failure. The second element |
|
84
|
|
|
|
|
|
|
is a hashref with either an error discription data, or the function's return result. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Success looks like this: |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$VAR1 = [ |
|
89
|
|
|
|
|
|
|
1, |
|
90
|
|
|
|
|
|
|
{ |
|
91
|
|
|
|
|
|
|
'status' => 'DOMAIN AVAILABLE', |
|
92
|
|
|
|
|
|
|
'type' => 'result', |
|
93
|
|
|
|
|
|
|
'domainname' => 'TEST123.TK', |
|
94
|
|
|
|
|
|
|
'domaintype' => 'FREE' |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
]; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Error looks like this: |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
$VAR1 = [ |
|
101
|
|
|
|
|
|
|
0, |
|
102
|
|
|
|
|
|
|
{ |
|
103
|
|
|
|
|
|
|
'reason' => 'Invalid domain name', |
|
104
|
|
|
|
|
|
|
'type' => 'Server Error' |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
]; |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
"type" can be 'Server Error' or 'Input Error'. 'Server Error' means the error was |
|
109
|
|
|
|
|
|
|
returned by API server Input Error relates to missed mandatory fields. Error message |
|
110
|
|
|
|
|
|
|
is in the "reason" field in both cases. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
|
113
|
|
|
|
|
|
|
|
|
114
|
1
|
|
|
1
|
|
137929
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
37
|
|
|
115
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
32
|
|
|
116
|
|
|
|
|
|
|
|
|
117
|
1
|
|
|
1
|
|
6
|
use REST::Client; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
18
|
|
|
118
|
1
|
|
|
1
|
|
5
|
use URI::Escape; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
67
|
|
|
119
|
1
|
|
|
1
|
|
436
|
use XML::Simple; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub new { |
|
122
|
|
|
|
|
|
|
my $class = shift; |
|
123
|
|
|
|
|
|
|
my $self = bless({}, $class); |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
$self->{_client} = REST::Client->new({ host => 'https://api.domainshare.tk', timeout => 10 }); |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
return $self; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub ping { |
|
131
|
|
|
|
|
|
|
my ($self) = @_; |
|
132
|
|
|
|
|
|
|
$self->_make_request('ping', undef, [], {}); |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub availability_check { |
|
136
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
137
|
|
|
|
|
|
|
$self->_make_request('availability_check', undef, ['email', 'password', 'domainname'], $args); |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub register { |
|
141
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
142
|
|
|
|
|
|
|
$self->_make_request('register', 'registration', ['email', 'password', 'domainname', 'enduseremail'], $args); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub renew { |
|
146
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
147
|
|
|
|
|
|
|
$self->_make_request('renew', undef, ['email', 'password', 'domainname'], $args); |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub host_registration { |
|
151
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
152
|
|
|
|
|
|
|
$self->_make_request('host_registration', undef, ['email', 'password', 'hostname', 'ipaddress'], $args); |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub host_removal { |
|
156
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
157
|
|
|
|
|
|
|
$self->_make_request('host_removal', undef, ['email', 'password', 'hostname'], $args); |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub host_list { |
|
161
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
162
|
|
|
|
|
|
|
$self->_make_request('host_list', undef, ['email', 'password', 'domainname'], $args); |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub modify { |
|
166
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
167
|
|
|
|
|
|
|
$self->_make_request('modify', undef, ['email', 'password', 'domainname'], $args); |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub resend_email { |
|
171
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
172
|
|
|
|
|
|
|
$self->_make_request('resend_email', undef, ['email', 'password', 'domainname'], $args); |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub domain_deactivate { |
|
176
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
177
|
|
|
|
|
|
|
$self->_make_request('domain_deactivate', undef, ['email', 'password', 'domainname', 'reason'], $args); |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub domain_reactivate { |
|
181
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
182
|
|
|
|
|
|
|
$self->_make_request('domain_reactivate', undef, ['email', 'password', 'domainname'], $args); |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub update_parking { |
|
186
|
|
|
|
|
|
|
my ($self, $args) = @_; |
|
187
|
|
|
|
|
|
|
$self->_make_request('update_parking', undef, ['email', 'password', 'domainname'], $args); |
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub _make_request { |
|
192
|
|
|
|
|
|
|
my ($self, $name, $xmlname, $fields, $args) = @_; |
|
193
|
|
|
|
|
|
|
$xmlname ||= $name; |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
my ($status, $errors) = check_mandatory_fields($args, @$fields); |
|
196
|
|
|
|
|
|
|
return ($status, $errors) unless ($status); |
|
197
|
|
|
|
|
|
|
$self->{_client}->POST("/$name", prepare_post_body($args) ); |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
print $self->{_client}->responseContent() if $::DotTKDebug; |
|
200
|
|
|
|
|
|
|
my $xc = XMLin($self->{_client}->responseContent()); |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
return parse_server_reply($xc, $xmlname); |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub prepare_post_body { |
|
206
|
|
|
|
|
|
|
my ($args) = @_; |
|
207
|
|
|
|
|
|
|
join ( '&', map { |
|
208
|
|
|
|
|
|
|
my $key = $_; |
|
209
|
|
|
|
|
|
|
if (ref $args->{$key} eq 'ARRAY') { |
|
210
|
|
|
|
|
|
|
my @a = map { URI::Escape::uri_escape($key) . '=' . URI::Escape::uri_escape($_) } @{$args->{$key}}; |
|
211
|
|
|
|
|
|
|
} else { |
|
212
|
|
|
|
|
|
|
URI::Escape::uri_escape($key) . '=' . URI::Escape::uri_escape($args->{$_}); |
|
213
|
|
|
|
|
|
|
} |
|
214
|
|
|
|
|
|
|
; |
|
215
|
|
|
|
|
|
|
} (keys %$args)); |
|
216
|
|
|
|
|
|
|
#join ( '&', (map { URI::Escape::uri_escape($_) . '=' . URI::Escape::uri_escape($args->{$_}) } keys %$args)); |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub check_mandatory_fields |
|
220
|
|
|
|
|
|
|
{ |
|
221
|
|
|
|
|
|
|
my ( $args, @names) = @_; |
|
222
|
|
|
|
|
|
|
for my $name (@names) { |
|
223
|
|
|
|
|
|
|
if ((!defined($args->{$name})) || (length($args->{$name}) == 0)) { |
|
224
|
|
|
|
|
|
|
return (0, { type => "Input error", reason => "$name is mandatory"} ); |
|
225
|
|
|
|
|
|
|
} |
|
226
|
|
|
|
|
|
|
} |
|
227
|
|
|
|
|
|
|
return (1, undef); |
|
228
|
|
|
|
|
|
|
} |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub parse_server_reply |
|
231
|
|
|
|
|
|
|
{ |
|
232
|
|
|
|
|
|
|
my ($xc, $namespace) = @_; |
|
233
|
|
|
|
|
|
|
if ($xc->{status} eq 'OK') { |
|
234
|
|
|
|
|
|
|
return (1, values_for($xc, $namespace)); |
|
235
|
|
|
|
|
|
|
} else { |
|
236
|
|
|
|
|
|
|
return (0, { type => "Server Error", reason => $xc->{reason} }); |
|
237
|
|
|
|
|
|
|
} |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
sub values_for |
|
241
|
|
|
|
|
|
|
{ |
|
242
|
|
|
|
|
|
|
my ($xc, $namespace) = @_; |
|
243
|
|
|
|
|
|
|
$xc->{"partner_$namespace"}; |
|
244
|
|
|
|
|
|
|
} |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
1; |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head1 AUTHOR |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
Dot TK DomainShare Program |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
254
|
|
|
|
|
|
|
the web interface at L. |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head1 SUPPORT |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
perldoc Domain::Register::DomainShare |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
You can also look for information at: |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=over 4 |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
L |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
L |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
L |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=item * Search CPAN |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
L |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=back |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Copyright (c) 2010 Dot TK Ltd. All Rights Reserved. This module is free software; you can redistribute it |
|
287
|
|
|
|
|
|
|
and/or modify it under the terms of either: a) the GNU General Public License as published by the Free |
|
288
|
|
|
|
|
|
|
Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License", |
|
289
|
|
|
|
|
|
|
that is, the same terms as Perl itself. |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
This module requires that the client user have an active account with Dot TK L in order |
|
292
|
|
|
|
|
|
|
to access it's key functionality. |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=cut |
|
295
|
|
|
|
|
|
|
|