PHP code example of justim / neostrada-api-client

1. Go to this page and download the library: Download justim/neostrada-api-client 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/ */

    

justim / neostrada-api-client example snippets


$neostrada = new Neostrada($apiKey, $secret);

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

// set A-record for www to 127.0.0.1
$domain->a('www', '127.0.0.1');

// you can do the same for CNAME-records
$domain->cname('autodiscover', 'autodiscover.outlook.com');

// alternatively you can get an instance of a record and make your changes there
$a = $domain->a('www');
$a->content = '10.0.0.2';
$a->ttl = 1800;

// making changes to current records doesn't automatically save changes
$domain->save();

$mxRecords = $domain->mx(); // lists all MX-records

foreach ($mxRecords as $mx)
{
	// change the content of the record
	$mx->content = 'mail.google.com';

	// mark the records as deleted
	$mx->setDeleted();
}

$mxRecords->save();

// adding records can be done by a new record and adding it
$a = $domain->create('a');
$a->name = 'mail';
$a->content = '127.0.0.1';
$domain->add($a); // adding a record saves it immediately

// fetching the auth code
$authCode = $domain->authCode();