PHP code example of bisnetis / php-epp2-coza

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

    

bisnetis / php-epp2-coza example snippets



AfriCC\EPP\Client as EPPClient;

$epp_client = new EPPClient([
    'host' => 'epptest.org',
    'username' => 'foo',
    'password' => 'bar',
    'services' => [
        'urn:ietf:params:xml:ns:domain-1.0',
        'urn:ietf:params:xml:ns:contact-1.0'
    ],
    'debug' => true,
]);

try {
    $greeting = $epp_client->connect();
} catch(Exception $e) {
    echo $e->getMessage() . PHP_EOL;
    unset($epp_client);
    exit(1);
}

$epp_client->close();


AfriCC\EPP\Frame\Command\Create\Host as CreateHost;

$frame = new CreateHost();
$frame->setHost('ns1.example.com');
$frame->setHost('ns2.example.com');
$frame->addAddr('8.8.8.8');
$frame->addAddr('8.8.4.4');
$frame->addAddr('2a00:1450:4009:809::1001');
echo $frame;

// or send frame to previously established connection
$epp_client->sendFrame($frame);

use AfriCC\EPP\Frame\Command\Check\Domain as DomainCheck;
use AfriCC\EPP\Frame\Response;

$frame = new DomainCheck();
$frame->addDomain('example.org');
$frame->addDomain('example.net');
$frame->addDomain('example.com');

$response = $epp_client->request($frame);
if (!($response instanceof Response)) {
    echo 'response error' . PHP_EOL;
    unset($epp_client);
    exit(1);
}

$result = $response->results()[0];

echo $result->code() . PHP_EOL;
echo $result->message() . PHP_EOL;
echo $response->clientTransactionId() . PHP_EOL;
echo $response->serverTransactionId() . PHP_EOL;
$data = $response->data();
if (empty($data) || !is_array($data)) {
    echo 'empty response data' . PHP_EOL;
    unset($epp_client);
    exit(1);
}

foreach ($data['chkData']['cd'] as $cd) {
    printf('Domain: %s, available: %d' . PHP_EOL, $cd['name'], $cd['@name']['avail']);
}

use AfriCC\EPP\HTTPClient as EPPClient;
use \AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;
use AfriCC\EPP\Frame\Command\Poll;

$objectSpec = new NASKObjectSpec();
$config = [
    'host' => 'https://app.registrar.tld',
    'username' => 'user',
    'password' => 'pass',
    'services' => $objectSpec->services,
    'serviceExtensions' => $objectSpec->serviceExtensions,
];

$epp_client = new EPPClient($config, $objectSpec);

$frame = new Poll($epp_client->getObjectSpec());

use AfriCC\EPP\Extension\NASK\Update\Future as UpdateFuture;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;

$frame = new UpdateFuture(new NASKObjectSpec());
$frame->setFuture('example7.pl');
$frame->changeRegistrant('mak21');
$frame->changeAuthInfo('2fooBAR');
echo $frame;

use AfriCC\EPP\ObjectSpec as DefaultObjectSpec;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;
use AfriCC\EPP\Client as EPPClient;
use AfriCC\EPP\HTTPClient as HTTPEPPClient;
use AfriCC\EPP\Frame\Command\Poll;

//...
$nask_objectspec = new NASKObjectSpec();
$default_objectspec = new DefaultObjectSpec();

$nask_client = new HTTPEPPClient($nask_config, $nask_objectspec);
$http_client = new HTTPEPPClient($http_config, $default_objectspec);
$socket_client = new EPPClient($socket_config, $default_objectspec);
$nask_socket_client = new EPPClient($nask_socket_config, $nask_objectspec);

$nask_poll = new Poll($nask_client->getObjectSpec());
$default_poll = new Poll($socket_client->getObjectSpec());

use AfriCC\EPP\ObjectSpec as DefaultObjectSpec;
use AfriCC\EPP\Extension\NASK\ObjectSpec as NASKObjectSpec;
use AfriCC\EPP\Client as EPPClient;

//...
$nask_objectspec = new NASKObjectSpec();
$default_objectspec = new DefaultObjectSpec();

$variable_client = new EPPClient($socket_config, $default_objectspec);

//calls to getObjectSpec will return default objectSpec and responses
//will be parsed using default ObjectSpec

$variable_client->setObjectSpec($nask_objectspec);

//calls to getObjectSpec will return NASK objectSpec and responses
//will be parsed using NASK ObjectSpec


$ composer