PHP code example of privyreza / rm-php-sdk

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

    

privyreza / rm-php-sdk example snippets




use Resellme\Client;

$client = new Client('your-api-token');

$domain = $client->domain()->search('example.com');

$response = $client->domain()->register([
    'domain' => 'example.com',
    'years' => 1,
    'contact_id' => 'contact-id',
]);

$response = $client->domain()->transfer([
    'domain' => 'example.com',
    'auth_code' => 'auth-code',
    'contact_id' => 'contact-id',
]);

$response = $client->domain()->renew('domain-id', [
    'years' => 1,
]);

$response = $client->hosting()->create([
    'domain' => 'example.com',
    'plan' => 'basic',
]);

$hostings = $client->hosting()->list();

$hosting = $client->hosting()->get('hosting-id');

$response = $client->hosting()->update('hosting-id', [
    'plan' => 'premium',
]);

$response = $client->hosting()->suspend('hosting-id');

$response = $client->hosting()->unsuspend('hosting-id');

$response = $client->hosting()->terminate('hosting-id');

$response = $client->vps()->create([
    'package_id' => 1,
    'hostname' => 'vps.example.com',
]);

$response = $client->vps()->manage('vps-id', 'reboot');

$nameservers = $client->nameserver()->list('domain-id');

$response = $client->nameserver()->update('domain-id', [
    'ns1.example.com',
    'ns2.example.com',
]);

$response = $client->nameserver()->add('domain-id', 'ns3.example.com');

$response = $client->nameserver()->delete('domain-id', 'ns3.example.com');

$response = $client->contact()->create([
    'first_name' => 'John',
    'last_name' => 'Doe',
    'email' => '[email protected]',
    'phone' => '+1234567890',
    'address' => '123 Main St',
    'city' => 'Example City',
    'country' => 'US',
]);

$response = $client->contact()->update('contact-id', [
    'email' => '[email protected]',
]);

$contact = $client->contact()->get('contact-id');

use Resellme\Exceptions\ApiException;
use Resellme\Exceptions\ServerException;

try {
    $domain = $client->domain()->search('example.com');
} catch (ApiException $e) {
    echo "API Error: " . $e->getMessage();
} catch (ServerException $e) {
    echo "Server Error: " . $e->getMessage();
} catch (\Exception $e) {
    echo "Unexpected Error: " . $e->getMessage();
}
bash
composer