1. Go to this page and download the library: Download balfour/domains-coza-api 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/ */
balfour / domains-coza-api example snippets
use GuzzleHttp\Client as Guzzle;
use Balfour\DomainsResellerAPI\Client;
$guzzle = new Guzzle();
$client = new Client($guzzle, 'your-api-key');
$response = $client->registerDomain(
'mydomain.co.za',
'Balfour Group (Pty) Ltd',
'[email protected]',
'+27.211111111',
'My Address Line 1',
'My Optional Address Line 2',
'8001',
'ZA',
'Balfour Group (Pty) Ltd',
'Cape Town',
'Western Cape',
1, // years - max of 1 year for co.za domains
true, // use managed nameservers
[],
'TEST1' // optional external ref
);
// using custom nameservers
$response = $client->registerDomain(
'mydomain.co.za',
'Balfour Group (Pty) Ltd',
'[email protected]',
'+27.211111111',
'My Address Line 1',
'My Optional Address Line 2',
'8001',
'ZA',
'Balfour Group (Pty) Ltd',
'Cape Town',
'Western Cape',
1, // years - max of 1 year for co.za domains
false, // not using managed nameservers
[
'ns1.foo.bar',
'ns2.foo.bar',
'ns3.foo.bar',
'ns4.foo.bar',
'ns5.foo.bar',
],
'TEST1' // optional external ref
);
// you can also register a domain using an implementation of RegistrantInterface
// eg: assuming $registrant is an implementation
$response = $client->registerDomainForRegistrant('mydomain.co.za', $registrant);
$response = $client->updateDomainRegistrant(
'mydomain.co.za',
'Balfour Group (Pty) Ltd',
'[email protected]',
'+27.211111111',
'My Address Line 1',
'My Optional Address Line 2',
'8001',
'ZA',
'Balfour Group (Pty) Ltd',
'Cape Town',
'Western Cape'
);
// you can also use an implementation of RegistrantInterface
$client->updateDomainRegistrantFromRegistrant('mydomain.co.za', $registrant);
use Badcow\DNS\AlignedBuilder;
$response = $client->getDNSRecords('mydomain.co.za');
var_dump($response->toArray());
foreach ($response->getRecords() as $record) {
var_dump($record->getType());
var_dump($record->getName());
var_dump($record->getContent());
var_dump($record->getPriority()); // only applicable to MX records
var_dump($record->getTTL());
}
// filter by type of record
$records = $response->getRecordsByType('MX');
// the records can be formatted as a zone file
$zone = $response->getZone();
echo AlignedBuilder::build($zone);
use Badcow\DNS\Rdata\Factory;
use Badcow\DNS\ResourceRecord;
// this example assumes no existing records
$a = new ResourceRecord;
$a->setName('sub.domain');
$a->setTtl(3600);
$a->setRdata(Factory::A('127.0.0.1'));
$mx = new ResourceRecord();
$mx->setName('@');
$mx->setRdata(Factory::Mx(10, 'mail-gw1.example.net.'));
$response = $client->updateDNSRecords('mydomain.co.za', [$a, $mx]);
// here, we first fetch the existing records, add a new record to the zone, then update passing in the zone
$response = $client->getDNSRecords('mydomain.co.za');
$zone = $response->getZone();
$a = new ResourceRecord;
$a->setName('sub.domain');
$a->setTtl(3600);
$a->setRdata(Factory::A('127.0.0.1'));
$zone->addResourceRecord($a);
// notice how we're just passing in a
$client->updateDNSRecordsFromZone($zone);
// you can also update the records from a local zone file
$client->updateDNSRecordsFromZoneFile('mydomain.co.za', '/path/to/zonefile');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.