|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Example; |
| 4 | + |
| 5 | +use Domainrobot\Domainrobot; |
| 6 | +use Domainrobot\Lib\DomainrobotAuth; |
| 7 | +use Domainrobot\Lib\DomainrobotException; |
| 8 | +use Domainrobot\Model\Domain; |
| 9 | +use Domainrobot\Model\NameServer; |
| 10 | +use Domainrobot\Model\ObjectJob; |
| 11 | + |
| 12 | +class SDKController |
| 13 | +{ |
| 14 | + /** |
| 15 | + * Create a premium domain |
| 16 | + * |
| 17 | + * For this task there are two prerequisites. |
| 18 | + * |
| 19 | + * First and most important is that the user is allowed to order premium domains (Reseller). |
| 20 | + * |
| 21 | + * Secondly you must know a premium domain with its price class. |
| 22 | + * You can achieve that for example by searching with the domainstudio task. |
| 23 | + * |
| 24 | + * |
| 25 | + * POST /domainstudio |
| 26 | + * { |
| 27 | + * "searchToken": "example.com", |
| 28 | + * "currency": "EUR" |
| 29 | + * } |
| 30 | + * |
| 31 | + * |
| 32 | + * In the /domainstudio Response look after the attribute "source": "PREMIUM". |
| 33 | + * |
| 34 | + * With an premium domain you selected you must now inquire its price class. |
| 35 | + * |
| 36 | + * |
| 37 | + * GET /domainpremium/examples.shop |
| 38 | + * |
| 39 | + * |
| 40 | + * In the /domainpremium Response look after the attribute "priceClass". |
| 41 | + * |
| 42 | + * @return ObjectJob |
| 43 | + */ |
| 44 | + public function domainCreatePremium() |
| 45 | + { |
| 46 | + // Create an domainrobot instance |
| 47 | + $domainrobot = new Domainrobot([ |
| 48 | + "url" => "https://api.autodns.com/v1", |
| 49 | + "auth" => new DomainrobotAuth([ |
| 50 | + "user" => "username", |
| 51 | + "password" => "password", |
| 52 | + "context" => 4 |
| 53 | + ]) |
| 54 | + ]); |
| 55 | + |
| 56 | + try { |
| 57 | + |
| 58 | + // Domainrobot\Model\Domain |
| 59 | + $domain = new Domain(); |
| 60 | + |
| 61 | + // Set the name of the premium domain |
| 62 | + $domain->setName("examples.shop"); |
| 63 | + |
| 64 | + // Set the inquired price class of the premium domain |
| 65 | + $domain->setPriceClass("SHOP-TIER9"); |
| 66 | + |
| 67 | + // Set the name servers of the premium domain |
| 68 | + $domain->setNameServers([ |
| 69 | + new NameServer([ |
| 70 | + "name" => "ns1.example.shop" |
| 71 | + ]), |
| 72 | + new NameServer([ |
| 73 | + "name" => "ns2.example.shop" |
| 74 | + ]), |
| 75 | + new NameServer([ |
| 76 | + "name" => "ns3.example.shop" |
| 77 | + ]) |
| 78 | + ]); |
| 79 | + |
| 80 | + // Load an existing domain contact |
| 81 | + // Domainrobot\Model\Contact |
| 82 | + $contact = $domainrobot->contact->info(23372784); |
| 83 | + |
| 84 | + // Set the necessary contact info with the loaded contact |
| 85 | + $domain->setAdminc($contact); |
| 86 | + $domain->setOwnerc($contact); |
| 87 | + $domain->setTechc($contact); |
| 88 | + $domain->setZonec($contact); |
| 89 | + |
| 90 | + // Domainrobot\Model\ObjectJob |
| 91 | + $objectJob = $domainrobot->domain->create($domain); |
| 92 | + |
| 93 | + } catch (DomainrobotException $exception) { |
| 94 | + return $exception; |
| 95 | + } |
| 96 | + |
| 97 | + return $objectJob; |
| 98 | + } |
| 99 | +} |
0 commit comments