-
Notifications
You must be signed in to change notification settings - Fork 12
/
DomainTransfer.php
68 lines (60 loc) · 2.1 KB
/
DomainTransfer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace Example;
use Domainrobot\Domainrobot;
use Domainrobot\Lib\DomainrobotAuth;
use Domainrobot\Lib\DomainrobotException;
use Domainrobot\Model\Domain;
use Domainrobot\Model\NameServer;
use Domainrobot\Model\ObjectJob;
/**
* This example is focused on a domain update the general principle holds true
* for ALL tasks you want to execute for a subuser of your auth user
*/
class SDKController
{
/**
* Transfer a domain
* returns an ObjectJob since the task itself is asynchronous
*
* @return ObjectJob
*/
public function domainTransfer()
{
$domainrobot = new Domainrobot([
"url" => "https://api.autodns.com/v1",
"auth" => new DomainrobotAuth([
"user" => "username",
"password" => "password",
"context" => 4
])
]);
try {
// Domainrobot/Model/Domain
$domain = new Domain();
$domain->setName("php-sdk-test".uniqid().".de");
$domain->setNameServers([
new NameServer([
"name" => "ns1.example.com"
]),
new NameServer([
"name" => "ns2.example.com"
])
]);
// in this example we use an already existing user
// but you can also create a completely new contact and use that one
// for an example of contact creation go to example/contact/ContactCreate.php
$contact = $domainrobot->contact->info(23194139);
$domain->setAdminc($contact);
$domain->setOwnerc($contact);
$domain->setTechc($contact);
$domain->setZonec($contact);
// this is just the bare minimum configuration for a transfer
// please refer https://help.internetx.com/display/APIJSONEN/Technical+Documentation
// for additional configuration options
$job = $domainrobot->domain->transfer($domain);
} catch (DomainrobotException $exception) {
return$exception;
}
return $job;
}
}