1. Go to this page and download the library: Download level23/dynadot-api 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/ */
level23 / dynadot-api example snippets
use Level23\Dynadot\Client;
$apiKey = 'xxx YOUR API KEY xxx';
$apiSecret = 'xxx YOUR API SECRET xxx';
try {
$client = new Client($apiKey, $apiSecret);
$domainInfo = $client->getDomainInfo('example.com');
// process your domain info here
print_r($domainInfo);
} catch (Exception $e) {
// ... handle exception
}
use Level23\Dynadot\Client;
$apiKey = 'xxx YOUR API KEY xxx';
$apiSecret = 'xxx YOUR API SECRET xxx';
try {
$client = new Client($apiKey, $apiSecret);
$domainList = $client->getDomainList();
foreach ($domainList->domains as $domain) {
echo $domain->domainName . "\n";
echo $domain->expiration . "\n";
}
} catch (Exception $e) {
// ... handle exception
}
use Level23\Dynadot\Client;
$apiKey = 'xxx YOUR API KEY xxx';
$apiSecret = 'xxx YOUR API SECRET xxx';
try {
$client = new Client($apiKey, $apiSecret);
$result = $client->setNameservers('example.com', ['ns01.example.com', 'ns2.example.net', 'ns03.example.org']);
// ...
} catch (Exception $e) {
// ... handle exception
}
use Level23\Dynadot\Client;
$apiKey = 'xxx YOUR API KEY xxx';
$apiSecret = 'xxx YOUR API SECRET xxx';
try {
$client = new Client($apiKey, $apiSecret);
$contact = $client->getContactInfo(1234); // 1234 = the contact id
print_r($contact);
} catch (Exception $e) {
echo $e->getMessage();
}
use Level23\Dynadot\Client;
$apiKey = 'xxx YOUR API KEY xxx';
$apiSecret = 'xxx YOUR API SECRET xxx';
try {
$client = new Client($apiKey, $apiSecret);
$contactList = $client->getContactList();
foreach ($contactList->contacts as $contact) {
echo "Contact ID: " . $contact->contactId . "\n";
echo "Name: " . $contact->name . "\n";
echo "Email: " . $contact->email . "\n";
echo "---\n";
}
} catch (Exception $e) {
echo $e->getMessage();
}
use Level23\Dynadot\Client;
$apiKey = 'xxx YOUR API KEY xxx';
$apiSecret = 'xxx YOUR API SECRET xxx';
try {
$client = new Client($apiKey, $apiSecret);
$result = $client->setRenewOption('example.com', 'auto');
// ...
} catch (Exception $e) {
// ... handle exception
}
use Level23\Dynadot\Client;
$apiKey = 'xxx YOUR API KEY xxx';
$apiSecret = 'xxx YOUR API SECRET xxx';
try {
$client = new Client($apiKey, $apiSecret);
$result = $client->search('example.com', true, 'USD');
echo "Domain: " . $result->domainName . "\n";
echo "Available: " . ($result->available ? 'Yes' : 'No') . "\n";
if ($result->available && isset($result->price)) {
echo "Price: $" . $result->price . "\n";
}
} catch (Exception $e) {
// ... handle exception
}
use Level23\Dynadot\Client;
$apiKey = 'xxx YOUR API KEY xxx';
$apiSecret = 'xxx YOUR API SECRET xxx';
try {
$client = new Client($apiKey, $apiSecret);
$domains = ['example.com', 'test.org', 'mydomain.net'];
$result = $client->bulkSearch($domains);
foreach ($result->domainResults as $domainResult) {
echo "Domain: " . $domainResult->domainName . "\n";
echo "Available: " . ($domainResult->available ? 'Yes' : 'No') . "\n";
echo "---\n";
}
} catch (Exception $e) {
// ... handle exception
}