PHP code example of simon80119 / godaddy-api-client
1. Go to this page and download the library: Download simon80119/godaddy-api-client library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
simon80119 / godaddy-api-client example snippets
{
""gellu/godaddy-api-client" : "1.*"
}
}
const API_KEY = ''; // key obtained from https://developer.godaddy.com
const API_SECRET = ''; // secret obtained from https://developer.godaddy.com
$domain = 'test-domain.com';
$domainPeriod = 1;
$domainAutoRenew = false;
$domainTLD = 'pl';
$contact = [
'name' => 'John',
'surname' => 'Doe',
'email' => '[email protected] ',
'phone' => '+48.111111111',
'organization' => 'Corporation Inc.',
'street' => 'Street Ave. 666',
'city' => 'New City',
'country' => 'PL',
'postal-code' => '11-111',
'state' => 'state of art'
];
$configuration = new \GoDaddyDomainsClient\Configuration();
$configuration->addDefaultHeader("Authorization", "sso-key ". API_KEY .":". API_SECRET);
$configuration->setDebug(true);
$apiClient = new \GoDaddyDomainsClient\ApiClient($configuration);
$apiInstance = new \GoDaddyDomainsClient\Api\VdomainsApi($apiClient);
$agreement = $apiInstance->getAgreement($domainTLD, false);
$agreementKeys = [$agreement[0]->getAgreementKey()];
$domainPurchase = new \GoDaddyDomainsClient\Model\DomainPurchase();
$domainPurchase->setDomain($domain);
$domainPurchaseConsent = new \GoDaddyDomainsClient\Model\Consent();
$domainPurchaseConsent->setAgreementKeys($agreementKeys);
$domainPurchaseConsent->setAgreedBy($contact['name'] . ' ' . $contact['surname']);
$domainPurchaseConsent->setAgreedAt(date("Y-m-d\TH:i:s\Z"));
$domainPurchase->setConsent($domainPurchaseConsent);
$domainContactAdmin = new \GoDaddyDomainsClient\Model\Contact();
$domainContactAdmin->setNameFirst($contact['name']);
$domainContactAdmin->setNameLast($contact['surname']);
$domainContactAdmin->setEmail($contact['email']);
$domainContactAdmin->setPhone($contact['phone']);
$domainContactAdmin->setOrganization($contact['organization']);
$domainContactAdminAddressMailing = new \GoDaddyDomainsClient\Model\Address();
$domainContactAdminAddressMailing->setAddress1($contact['street']);
$domainContactAdminAddressMailing->setCity($contact['city']);
$domainContactAdminAddressMailing->setCountry($contact['country']);
$domainContactAdminAddressMailing->setPostalCode($contact['postal-code']);
$domainContactAdminAddressMailing->setState($contact['state']);
$domainContactAdmin->setAddressMailing($domainContactAdminAddressMailing);
$domainPurchase->setContactAdmin($domainContactAdmin);
$domainPurchase->setContactBilling($domainContactAdmin);
$domainPurchase->setContactRegistrant($domainContactAdmin);
$domainPurchase->setContactTech($domainContactAdmin);
$domainPurchase->setPeriod($domainPeriod);
$domainPurchase->setRenewAuto($domainAutoRenew);
$purchase = $apiInstance->purchase($domainPurchase);