-
Notifications
You must be signed in to change notification settings - Fork 12
/
DomainBuy.php
85 lines (72 loc) · 2.47 KB
/
DomainBuy.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
namespace Example;
use Domainrobot\Domainrobot;
use Domainrobot\Lib\DomainrobotAuth;
use Domainrobot\Lib\DomainrobotException;
use Domainrobot\Model\Domain;
use Domainrobot\Model\DomainExtensions;
use Domainrobot\Model\DomainBuyExtensions;
use Domainrobot\Model\NameServer;
use Domainrobot\Model\ObjectJob;
class SDKController
{
/**
* Buy a domain of the Sedo premium market.
*
* IMPORTANT: As of now this task does not work in an sandbox enviroment,
* because of the necessity to query the price of an domain
* from Sedo (which only works live).
*
* @return ObjectJob
*/
public function domainCreatePremium()
{
// Create an domainrobot instance
$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();
// Set the name of domain wanted to buy
$domain->setName("sedo-example.com");
// Set the price and currency of the domain wanted to buy
$domain->setExtensions(new DomainExtensions([
'domainBuyExtensions' => new DomainBuyExtensions([
'amount' => 76,
'currency' => "EUR"
]),
]));
// Set the name servers of the domain
$domain->setNameServers([
new NameServer([
"name" => "ns1.example.com"
]),
new NameServer([
"name" => "ns2.example.com"
]),
new NameServer([
"name" => "ns3.example.com"
])
]);
// Load an existing domain contact
// Domainrobot\Model\Contact
$contact = $domainrobot->contact->info(23372787);
// Set the necessary contact info with the loaded contact
$domain->setAdminc($contact);
$domain->setOwnerc($contact);
$domain->setTechc($contact);
$domain->setZonec($contact);
// Domainrobot\Model\ObjectJob
$objectJob = $domainrobot->domain->buy($domain);
} catch (DomainrobotException $exception) {
return $exception;
}
return $objectJob;
}
}