PHP code example of revoltify / spaceship-php

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

    

revoltify / spaceship-php example snippets


use Spaceship\SpaceshipAPI;

$api = new SpaceshipAPI('api_key', 'api_secret');

// Get domain information
$api->domain('example.com');

// Update nameservers
$params = NameserverParams::make()
    ->setProvider('custom')
    ->setHosts(['ns1.example.com', 'ns2.example.com']);

$api->updateNameserver('example.com', $params);

// Get domain auth code
$api->authCode('example.com');

// Update privacy protection
$params = PrivacyProtectionParams::make()
    ->setPrivacyLevel(PrivacyLevel::PUBLIC); // or PrivacyLevel::HIGH

$api->updatePrivacyProtection('example.com', $params);

// Lock domain transfer
$params = TransferLockParams::make()->lock();

// Unlock domain transfer
$params = TransferLockParams::make()->unlock();

$api->updateTransferLock('example.com', $params);

// Create new contact
$params = CreateContactParams::make()
    ->setFirstName('John')
    ->setLastName('Doe')
    ->setEmail('[email protected]')
    ->setAddress1('Dhaka')
    ->setCity('Dhaka')
    ->setCountryCode('BD')
    ->setPostalCode('1234')
    ->setPhone('+880.1333333333');

$api->createContact($params);

// Get contact information
$api->contact('5HebrteUuESDiv2TyC60yFpJw1oZ');

// Update contact
$params = UpdateContactParams::make()
    ->setRegistrant('1gFvGJ8mwW6t3lb2ovtUCP2YUDD')
    ->setAdmin('1gFvGJ8mwW6t3lb2ovtUCP2YUDD')
    ->setTech('1gFvGJ8mwW6t3lb2ovtUCP2YUDD')
    ->setBilling('1gFvGJ8mwW6t3lb2ovtUCP2YUDD');

$api->updateContact('example.com', $params);

try {
    $api = new SpaceshipAPI('api_key', 'api_secret');
} catch (SpaceshipException $e) {
    // Handle error
}
bash
composer