<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', true);
ini_set('display_errors', true);
include_once '../Api.php';
try {
    $config = new \Namecheap\Config();
    $config->apiUser('api-username')->apiKey('api-key')->clientIp('your-ip')->sandbox(true);
    $command = Namecheap\Api::factory($config, 'domains.dns.setDefault');
    $command->domainName('example1.com')->dispatch();
} catch (\Exception $e) {
    die($e->getMessage());
}
d($command);
function d($value = array())
{
    echo '<pre>' . "\n";
    print_r($value);
    die('</pre>' . "\n");
}
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', true);
ini_set('display_errors', true);
include_once '../Api.php';
try {
    $config = new \Namecheap\Config();
    $config->apiUser('api-username')->apiKey('api-key')->clientIp('your-ip')->sandbox(true);
    $command = Namecheap\Api::factory($config, 'domains.dns.getList');
    $command->domainName('example1.com')->dispatch();
} catch (\Exception $e) {
    die($e->getMessage());
}
d($command);
function d($value = array())
{
    echo '<pre>' . "\n";
    print_r($value);
    die('</pre>' . "\n");
}
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', true);
ini_set('display_errors', true);
include_once '../Api.php';
try {
    $config = new \Namecheap\Config();
    $config->apiUser('api-username')->apiKey('api-key')->clientIp('your-ip')->sandbox(true);
    $command = Namecheap\Api::factory($config, 'domains.check');
    $command->domainList(array('example1.com', 'example2.me', 'acdealjfe.com'))->dispatch();
} catch (\Exception $e) {
    die($e->getMessage());
}
// Check single domain
echo 'example1.com ';
echo $command->isAvailable('example1.com') === true ? ' available' : ' not available';
echo "<br/>\n";
// Throws exception
echo 'billybob.com';
echo $command->isAvailable('billybob.com') === true ? ' available' : ' not available';
echo "<br/>\n";
foreach ($command->domains as $domain => $available) {
    echo $domain;
    echo $available === true ? ' available' : ' not available';
    echo "<br/>\n";
}
function d($value = array())
{
    echo '<pre>' . "\n";
    print_r($value);
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', true);
ini_set('display_errors', true);
include_once '../Api.php';
try {
    $config = new \Namecheap\Config();
    $config->apiUser('api-username')->apiKey('api-key')->clientIp('your-ip')->sandbox(true);
    $command = Namecheap\Api::factory($config, 'domains.ns.create');
    $command->domainName('example1.com')->nameserver('ns1.example1.com')->ip('192.168.1.1')->dispatch();
} catch (\Exception $e) {
    die($e->getMessage());
}
if ($command->status() == 'error') {
    die($command->errorMessage);
}
d($command);
function d($value = array())
{
    echo '<pre>' . "\n";
    print_r($value);
    die('</pre>' . "\n");
}
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', true);
ini_set('display_errors', true);
include_once '../Api.php';
try {
    $config = new \Namecheap\Config();
    $config->apiUser('api-username')->apiKey('api-key')->clientIp('your-ip')->sandbox(true);
    $command = Namecheap\Api::factory($config, 'users.getBalances');
    $command->dispatch();
} catch (\Exception $e) {
    die($e->getMessage());
}
d($command);
function d($value = array())
{
    echo '<pre>' . "\n";
    print_r($value);
    die('</pre>' . "\n");
}
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', true);
ini_set('display_errors', true);
include_once '../Api.php';
try {
    $config = new \Namecheap\Config();
    $config->apiUser('api-username')->apiKey('api-key')->clientIp('your-ip')->sandbox(true);
    $command = Namecheap\Api::factory($config, 'users.getPricing');
    $command->setParams(array('ProductType' => 'DOMAIN', 'ProductCategory' => 'REGISTER'))->dispatch();
} catch (\Exception $e) {
    die($e->getMessage());
}
d($command);
function d($value = array())
{
    echo '<pre>' . "\n";
    print_r($value);
    die('</pre>' . "\n");
}
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', true);
ini_set('display_errors', true);
include_once '../Api.php';
try {
    $config = new \Namecheap\Config();
    $config->apiUser('api-username')->apiKey('api-key')->clientIp('your-ip')->sandbox(true);
    $command = Namecheap\Api::factory($config, 'domains.getContacts');
    $command->domainName('example1.com')->dispatch();
} catch (\Exception $e) {
    die($e->getMessage());
}
d($command);
function d($value = array())
{
    echo '<pre>' . "\n";
    print_r($value);
    die('</pre>' . "\n");
}
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', true);
ini_set('display_errors', true);
include_once '../Api.php';
try {
    $config = new \Namecheap\Config();
    $config->apiUser('api-username')->apiKey('api-key')->clientIp('your-ip')->sandbox(true);
    $command = Namecheap\Api::factory($config, 'domains.dns.setCustom');
    $command->domainName('example1.com')->nameservers(array('ns1.example1.com', 'ns2.example1.com'))->dispatch();
} catch (\Exception $e) {
    die($e->getMessage());
}
d($command);
function d($value = array())
{
    echo '<pre>' . "\n";
    print_r($value);
    die('</pre>' . "\n");
}
    $command->domainName('example1.com')->dispatch();
    
    if ($record = $command->getHostById('123'))
    {
    	$record->setData('example1.com');
    }
    
    if ($record = $command->getHostById('123'))
    {
    	$record->setData('192.168.1.1');
    }
    */
    #	$record = new Namecheap\DnsRecord();
    #	$command->addHost($record);
    #	$command->removeHost(1);
    $command = Namecheap\Api::factory($config, 'domains.dns.setHosts');
    $command->domainName('example1.com');
    $record = new Namecheap\DnsRecord();
    $record->setType('A')->setHost('@')->setData('192.168.1.1');
    $command->addHost($record);
    $record = new Namecheap\DnsRecord();
    $record->setType('cname')->setHost('www')->setData('example1.com');
    $command->addHost($record);
    $command->dispatch();
} catch (\Exception $e) {
    die($e->getMessage());
}
d($command);
function d($value = array())
{
    echo '<pre>' . "\n";
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', true);
ini_set('display_errors', true);
include_once '../Api.php';
try {
    $config = new \Namecheap\Config();
    $config->apiUser('api-username')->apiKey('api-key')->clientIp('your-ip')->sandbox(true);
    $command = Namecheap\Api::factory($config, 'domains.ns.getInfo');
    $command->domainName('example1.com')->nameserver('ns1.example1.com')->dispatch();
} catch (\Exception $e) {
    die($e->getMessage());
}
if ($command->status() == 'error') {
    die($command->errorMessage);
}
d($command);
function d($value = array())
{
    echo '<pre>' . "\n";
    print_r($value);
    die('</pre>' . "\n");
}
<?php

error_reporting(E_ALL | E_STRICT);
ini_set('display_startup_errors', true);
ini_set('display_errors', true);
include_once '../Api.php';
try {
    $config = new \Namecheap\Config();
    $config->apiUser('api-username')->apiKey('api-key')->clientIp('your-ip')->sandbox(true);
    $command = Namecheap\Api::factory($config, 'domains.renew');
    $command->setParams(array('DomainName' => 'example1.com', 'Years' => 1))->dispatch();
} catch (\Exception $e) {
    die($e->getMessage());
}
if ($command->status() == 'error') {
    die($command->errorMessage);
}
d($command);
function d($value = array())
{
    echo '<pre>' . "\n";
    print_r($value);
    die('</pre>' . "\n");
}