1. Go to this page and download the library: Download opusdns/php-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/ */
opusdns / php-client example snippets
use OpusDNS\Client\Client;
use OpusDNS\Client\Config;
use OpusDNS\Client\Enum\PeriodUnit;
use OpusDNS\Client\Enum\RenewalMode;
use OpusDNS\Client\Model\ContactHandle;
use OpusDNS\Client\Model\DomainCreate;
use OpusDNS\Client\Model\DomainPeriod;
use OpusDNS\Client\Model\Nameserver;
$client = Client::create(Config::sandbox('opk_your_api_key'));
// Is the name available?
$check = $client->domain()->eppCheckDomain(['example.com']);
if (!$check->results[0]->available) {
exit('taken');
}
// Register it for one year with an existing contact.
$domain = $client->domain()->createDomain(new DomainCreate(
contacts: ['registrant' => [new ContactHandle('contact_01h45ytscbebyvny4gc8cr8ma2')]],
name: 'example.com',
period: new DomainPeriod(PeriodUnit::Y, 1),
renewalMode: RenewalMode::EXPIRE,
nameservers: [new Nameserver('ns1.example.net'), new Nameserver('ns2.example.net')],
));
echo $domain->expiresOn?->format('Y-m-d');
use OpusDNS\Client\Client;
use OpusDNS\Client\Config;
$config = new Config(
apiKey: 'opk_...',
baseUrl: Config::PRODUCTION_URL, // or Config::SANDBOX_URL
userAgent: 'my-billing-app/2.0', // defaults to the client token
headers: ['X-Request-Source' => 'billing'],
timeout: 30.0, // seconds, applied when Client::create() builds Guzzle
connectTimeout: 5.0,
clientToken: 'my-billing-app/2.0', // sent as X-OpusDNS-Client; '' omits the header
);
// Guzzle, built by the client
$client = Client::create($config);
// Any PSR-18 client with PSR-17 request and stream factories
$client = new Client($config, $psr18Client, $requestFactory, $streamFactory);
$domain = $client->domain()->getDomain('example.com');
$renewal = $client->domain()->renewDomain('example.com', new DomainRenewRequest(
currentExpiryDate: new \DateTimeImmutable('2027-01-31T10:00:00Z'),
period: new DomainPeriod(PeriodUnit::Y, 1),
));
echo $renewal->newExpiryDate->format('Y-m-d');
$client->domain()->transferDomain(new DomainTransferIn('example.org', RenewalMode::RENEW, authCode: 'epp-code'));
$client->domain()->updateDomain('example.com', new DomainUpdate(renewalMode: RenewalMode::RENEW));
$contact = $client->contact()->createContact(new ContactCreate(
city: 'Berlin', country: 'DE', disclose: false, email: '[email protected]',
firstName: 'Jane', lastName: 'Doe', phone: '+49.301234567', postalCode: '10115', street: 'Unter den Linden 1',
));
$zone = $client->dns()->getZone('example.com');
$client->dns()->patchZoneRrsets('example.com', new DnsZoneRrsetsPatchOps([
new DnsRrsetPatchOp(PatchOp::UPSERT, new DnsRrsetPatch('www.example.com.', [['rdata' => '192.0.2.1']], 3600, DnsRrsetType::A)),
]));