/**
  * update a contact if it exists
  * @param \AfriCC\EPP\Client $epp_client
  * @param int $contact_id
  * @param array $params
  */
 public static function updateContactIfExists(\AfriCC\EPP\Client $epp_client, $contact_id, array $params)
 {
     // probe contact-id
     $frame = new \AfriCC\EPP\Frame\Command\Info\Contact();
     $frame->setId($contact_id);
     $response = $epp_client->request($frame);
     unset($frame);
     if (!$response instanceof \AfriCC\EPP\Frame\Response) {
         throw new Exception('COZA/ContactInfo: unable to get response');
     }
     // contact does not exist, so skip
     if ($response->code() === 2303) {
         return;
     }
     $frame = new \AfriCC\EPP\Frame\Command\Update\Contact();
     $frame->setId($contact_id);
     $frame->changeName($params['fullname']);
     $frame->changeOrganization($params['companyname']);
     $frame->changeAddStreet($params['address1']);
     $frame->changeAddStreet($params['address2']);
     $frame->changeCity($params['city']);
     $frame->changePostalCode($params['postcode']);
     $frame->changeCountryCode($params['countrycode']);
     $frame->changeVoice($params['phonenumberformatted']);
     $frame->changeEmail($params['email']);
     $upd_response = $epp_client->request($frame);
     unset($frame);
     if (!$upd_response instanceof \AfriCC\EPP\Frame\Response) {
         throw new Exception('COZA/ContactUpdate: unable to get response');
     }
     if (!$upd_response->success()) {
         throw new Exception(sprintf('COZA/ContactUpdate: %s (%d)', $upd_response->message(), $upd_response->code()));
     }
     return true;
 }
Example #2
0
<?php

// debug
error_reporting(E_ALL);
ini_set('display_errors', true);
chdir(__DIR__);
require '../src/AfriCC/autoload.php';
use AfriCC\EPP\Client as EPPClient;
$epp_client = new EPPClient(['host' => 'epptest.org', 'username' => 'gunter', 'password' => 'grodotzki', '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();