PHP code example of domainreseller / php-dna

1. Go to this page and download the library: Download domainreseller/php-dna 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/ */

    

domainreseller / php-dna example snippets


// SOAP mode (legacy credentials)
$dna = new \DomainNameApi\DomainNameAPI_PHPLibrary('myreseller', 'mypassword');

// REST mode (UUID credentials)
$dna = new \DomainNameApi\DomainNameAPI_PHPLibrary('fd2bea54-99ea-16b6-c195-3a1b9079df00', 'your-api-token');

// Both modes use the exact same method calls
$details = $dna->GetResellerDetails();
$domains = $dna->GetList();



$dna = new \DomainNameApi\DomainNameAPI_PHPLibrary('username','password');



$dna = new \DomainNameApi\DomainNameAPI_PHPLibrary('username','password');

$contact = [
    "FirstName"        => 'John',
    "LastName"         => 'Doe',
    "Company"          => 'Example Corp',
    "EMail"            => '[email protected]',
    "AddressLine1"     => '123 Lorem Street',
    "AddressLine2"     => 'Suite 456',
    "AddressLine3"     => '',
    "City"             => 'Springfield',
    "Country"          => 'US',
    "Fax"              => '1234567890',
    "FaxCountryCode"   => '1',
    "Phone"            => '9876543210',
    "PhoneCountryCode" => 1,
    "Type"             => 'Contact',
    "ZipCode"          => '12345',
    "State"            => 'IL'
];

$dna->RegisterWithContactInfo(
    'example.com',
    1,
    [
        'Administrative' => $contact,
        'Billing'        => $contact,
        'Technical'      => $contact,
        'Registrant'     => $contact
    ],
    ["ns1.example.com", "ns2.example.com"],
    true,
    false,
    // Additional attributes are only 

Array
(
    [result] => OK
    [data] => Array
    (
        [ID] => 123456
        [Status] => clientTransferProhibited
        [DomainName] => example.com
        [AuthCode] => Xy9#mK2$pL5@vN8
        [LockStatus] => true
        [PrivacyProtectionStatus] => false
        [IsChildNameServer] => false
        [Contacts] => Array
        (
            [Billing] => Array
            (
                [ID] => 987654
            )
            [Technical] => Array
            (
                [ID] => 987654
            )
            [Administrative] => Array
            (
                [ID] => 987654
            )
            [Registrant] => Array
            (
                [ID] => 987654
            )
        )
        [Dates] => Array
        (
            [Start] => 2024-03-15T10:00:00
            [Expiration] => 2025-03-15T10:00:00
            [RemainingDays] => 365
        )
        [NameServers] => Array
        (
            [0] => ns1.example.com
            [1] => ns2.example.com
        )
        [Additional] => Array
        (
        )
        [ChildNameServers] => Array
        (
        )
    )
)

$dna->Renew('example.com', 1);

Array
(
    [result] => OK
    [data] => Array
    (
        [ExpirationDate] => 2025-03-15T10:00:00
    )
)

$dna->Transfer('example.com', 'Xy9#mK2$', 3);

Array
(
    [result] => OK
)

$dna->GetList(['OrderColumn'=>'Id', 'OrderDirection'=>'ASC', 'PageNumber'=>0,'PageSize'=>1000]);

Array
(
    [data] => Array
    (
        [Domains] => Array
        (
            [0] => Array
            (
                [ID] => 564346
                [Status] => Active
                [DomainName] => example.com
                [AuthCode] => DHQ!K52
                [LockStatus] => false
                [PrivacyProtectionStatus] => false
                [IsChildNameServer] => false
                [Contacts] => Array
                (
                    [Billing] => Array
                    (
                        [ID] => 11854114
                    )
                    [Technical] => Array
                    (
                        [ID] => 11854114
                    )
                    [Administrative] => Array
                    (
                        [ID] => 11854114
                    )
                    [Registrant] => Array
                    (
                        [ID] => 11854114
                    )
                )
                [Dates] => Array
                (
                    [Start] => 2024-03-15T10:00:00
                    [Expiration] => 2025-03-15T10:00:00
                    [RemainingDays] => 365
                )
                [NameServers] => Array
                (
                    [0] => ns1.example.com
                    [1] => ns2.example.com
                )
                [Additional] => Array
                (
                )
                [ChildNameServers] => Array
                (
                    [0] => Array
                    (
                        [ns] => ns1.example.com
                        [ip] => 1.2.3.4
                    )
                )
            )
        )
    )
    [result] => OK
    [TotalCount] => 1
)

$dna->GetTldList(100);

Array
(
    [data] => Array
        (
            [0] => Array
                (
                    [id] => 1
                    [status] => Active
                    [maxchar] => 63
                    [maxperiod] => 10
                    [minchar] => 1
                    [minperiod] => 1
                    [tld] => com
                    [pricing] => Array
                        (
                            [registration] => Array
                                (
                                    [1] => 10.8100
                                )
                            [renew] => Array
                                (
                                    [1] => 11.0100
                                )
                            [transfer] => Array
                                (
                                    [1] => 10.6100
                                )
                            [restore] => Array
                                (
                                    [1] => 99.9000
                                )
                        )
                    [currencies] => Array
                        (
                            [registration] => USD
                            [renew] => USD
                            [transfer] => USD
                            [restore] => USD
                        )
                )
        )
    [result] => OK
)

$dna->CheckAvailability(['hello','world123x0'], ['com','net'], 1, 'create');

Array
(
    [0] => Array
        (
            [TLD] => com
            [DomainName] => hello
            [Status] => notavailable
            [Command] => create
            [Period] => 1
            [IsFee] =>
            [Price] => 10.8100
            [Currency] => USD
            [Reason] => Domain exists
        )

    [1] => Array
        (
            [TLD] => com
            [DomainName] => world123x0
            [Status] => available
            [Command] => create
            [Period] => 1
            [IsFee] =>
            [Price] => 10.8100
            [Currency] => USD
            [Reason] =>
        )
)

$dna->GetDetails('example.com');

Array
(
    [data] => Array
        (
            [ID] => 564346
            [Status] => Active
            [DomainName] => example.com
            [AuthCode] => DHQ!K52
            [LockStatus] => true
            [PrivacyProtectionStatus] => false
            [IsChildNameServer] => false
            [Contacts] => Array
                (
                    [Billing] => Array
                        (
                            [ID] => 11854114
                        )
                    [Technical] => Array
                        (
                            [ID] => 11854114
                        )
                    [Administrative] => Array
                        (
                            [ID] => 11854114
                        )
                    [Registrant] => Array
                        (
                            [ID] => 11854114
                        )
                )
            [Dates] => Array
                (
                    [Start] => 2025-05-26T16:08:37
                    [Expiration] => 2027-05-26T16:08:37
                    [RemainingDays] => 449
                )
            [NameServers] => Array
                (
                    [0] => ns1.example.com
                    [1] => ns2.example.com
                )
            [Additional] => Array
                (
                )
            [ChildNameServers] => Array
                (
                    [0] => Array
                        (
                            [ns] => ns1.example.com
                            [ip] => 1.2.3.4
                        )
                )
        )
    [result] => OK
)

$dna->ModifyNameServer('example.com', ['ns1.example.com', 'ns2.example.com']);

Array
(
    [data] => Array
        (
            [NameServers] => Array
                (
                    [0] => ns1.example.com
                    [1] => ns2.example.com
                )
        )
    [result] => OK
)

$dna->EnableTheftProtectionLock('example.com');

Array
(
    [data] => Array
        (
            [LockStatus] => true
        )
    [result] => OK
)

$dna->DisableTheftProtectionLock('example.com');

Array
(
    [data] => Array
        (
            [LockStatus] => false
        )
    [result] => OK
)

$dna->AddChildNameServer('example.com', 'ns1.example.com', '1.2.3.4');

Array
(
    [data] => Array
        (
            [NameServer] => ns1.example.com
            [IPAdresses] => Array
                (
                    [0] => 1.2.3.4
                )
        )
    [result] => OK
)

$dna->DeleteChildNameServer('example.com', 'ns1.example.com');

Array
(
    [data] => Array
        (
            [NameServer] => ns1.example.com
        )
    [result] => OK
)

$dna->ModifyChildNameServer('example.com', 'ns1.example.com', '1.2.3.4');

Array
(
    [data] => Array
        (
            [NameServer] => ns1.example.com
            [IPAdresses] => Array
                (
                    [0] => 1.2.3.4
                )
        )
    [result] => OK
)

$dna->ModifyPrivacyProtectionStatus('example.com', true, 'Owner request');

Array
(
    [data] => Array
        (
            [PrivacyProtectionStatus] => true
        )
    [result] => OK
)

$contact = [
    "FirstName"        => 'John',
    "LastName"         => 'Doe',
    "Company"          => 'Example Corp',
    "EMail"            => '[email protected]',
    "AddressLine1"     => '123 Main Street',
    "AddressLine2"     => '',
    "AddressLine3"     => '',
    "City"             => 'Springfield',
    "Country"          => 'US',
    "Fax"              => '5559876543',
    "FaxCountryCode"   => '1',
    "Phone"            => '5551234567',
    "PhoneCountryCode" => 1,
    "Type"             => 'Contact',
    "ZipCode"          => '62701',
    "State"            => 'IL'
];

$dna->SaveContacts('example.com', [
    'Administrative' => $contact,
    'Billing'        => $contact,
    'Technical'      => $contact,
    'Registrant'     => $contact
]);

Array
(
    [result] => OK
)

$dna->GetResellerDetails();

Array
(
    [result] => OK
    [id] => 12345
    [active] => 1
    [name] => Example Reseller
    [balance] => 500.0000
    [currency] => USD
    [symbol] => $
    [balances] => Array
        (
            [0] => Array
                (
                    [balance] => 500.0000
                    [currency] => USD
                    [symbol] => $
                )
            [1] => Array
                (
                    [balance] => 1500.0000
                    [currency] => TL
                    [symbol] => TL
                )
        )
)
bash
composer