/** * Gets the singleton SoapClient which is used to connect to the TransIP Api. * * @param mixed $parameters Parameters. * @return SoapClient The SoapClient object to which we can connect to the TransIP API */ public static function _getSoapClient($parameters = array()) { $endpoint = Transip_ApiSettings::$endpoint; if (self::$_soapClient === null) { $extensions = get_loaded_extensions(); $errors = array(); if (!class_exists('SoapClient') || !in_array('soap', $extensions)) { $errors[] = 'The PHP SOAP extension doesn\'t seem to be installed. You need to install the PHP SOAP extension. (See: http://www.php.net/manual/en/book.soap.php)'; } if (!in_array('openssl', $extensions)) { $errors[] = 'The PHP OpenSSL extension doesn\'t seem to be installed. You need to install PHP with the OpenSSL extension. (See: http://www.php.net/manual/en/book.openssl.php)'; } if (!empty($errors)) { die('<p>' . implode("</p>\n<p>", $errors) . '</p>'); } $classMap = array('DomainCheckResult' => 'Transip_DomainCheckResult', 'Domain' => 'Transip_Domain', 'Nameserver' => 'Transip_Nameserver', 'WhoisContact' => 'Transip_WhoisContact', 'DnsEntry' => 'Transip_DnsEntry', 'DomainBranding' => 'Transip_DomainBranding', 'Tld' => 'Transip_Tld', 'DomainAction' => 'Transip_DomainAction'); $options = array('classmap' => $classMap, 'encoding' => 'utf-8', 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'trace' => false); $wsdlUri = "https://{$endpoint}/wsdl/?service=" . self::SERVICE; try { self::$_soapClient = new SoapClient($wsdlUri, $options); } catch (SoapFault $sf) { throw new Exception("Unable to connect to endpoint '{$endpoint}'"); } self::$_soapClient->__setCookie('login', Transip_ApiSettings::$login); self::$_soapClient->__setCookie('mode', Transip_ApiSettings::$mode); } $timestamp = time(); $nonce = uniqid('', true); self::$_soapClient->__setCookie('timestamp', $timestamp); self::$_soapClient->__setCookie('nonce', $nonce); self::$_soapClient->__setCookie('clientVersion', self::API_VERSION); self::$_soapClient->__setCookie('signature', self::_urlencode(self::_sign(array_merge($parameters, array('__service' => self::SERVICE, '__hostname' => $endpoint, '__timestamp' => $timestamp, '__nonce' => $nonce))))); return self::$_soapClient; }
* @author TransIP BV <*****@*****.**> */ // Include domainservice require_once 'Transip/DomainService.php'; try { // Transfers a domain with your default settings // It's also possible to transfer with custom settings, // for this the call should be like: // $domain = new Transip_Domain('transip.nl', <array of nameservers>, <array of contacts>, // <array of dns entries>); $domainName = 'example.com'; $authCode = '[AUTHCODE]'; $domain = new Transip_Domain($domainName); $tldName = strstr($domainName, '.'); $tldInfo = Transip_DomainService::getTldInfo($tldName); if (in_array(Transip_Tld::CAPABILITY_CANTRANSFERWITHOWNERCHANGE, $tldInfo->capabilities)) { Transip_DomainService::transferWithOwnerChange($domain, $authCode); } elseif (in_array(Transip_Tld::CAPABILITY_CANTRANSFERWITHOUTOWNERCHANGE, $tldInfo->capabilities)) { Transip_DomainService::transferWithoutOwnerChange($domain, $authCode); } else { // The TLD does not support transfers at all throw new Exception('TLD ' . $tldName . ' does not support domain transfers'); } echo 'The domain ' . $domain->name . ' has been requested.'; } catch (SoapFault $f) { // It is possible that an error occurs when connecting to the TransIP Soap API, // those errors will be thrown as a SoapFault exception. echo 'An error occurred: ' . htmlspecialchars($f->getMessage()); } catch (Exception $e) { echo htmlspecialchars($e->getMessage()); }
$newContact->street = $_POST[$type]['street']; $newContact->number = $_POST[$type]['number']; $newContact->postalCode = $_POST[$type]['postalCode']; $newContact->city = $_POST[$type]['city']; $newContact->country = $_POST[$type]['country']; $newContact->phoneNumber = $_POST[$type]['phoneNumber']; $newContact->faxNumber = $_POST[$type]['faxNumber']; $newContact->email = $_POST[$type]['email']; // Add new contact to the list $newContacts[] = $newContact; } // Set contacts for the domain by using the Transip_DomainService API; Transip_DomainService::setContacts($domain, $newContacts); } // Request the locked status of a domain by using the Transip_DomainService API; $info = Transip_DomainService::getInfo($domain); // The Transip_Domain object contains an array of Transip_WhoisContact objects // Each Transip_WhoisContact object has one of three types // Iterate through contacts and save in array foreach ($info->contacts as $contact) { $contacts[$contact->type] = $contact; } } catch (SoapFault $e) { // It is possible that an error occurs when connecting to the TransIP Soap API, // those errors will be thrown as a SoapFault exception. $error = 'An error occurred: ' . htmlspecialchars($e->getMessage()); } } else { $domain = ''; $isLocked = false; }
<?php /** * This example registers a domain with custom nameservers. * * @copyright Copyright 2011 TransIP BV * @author TransIP BV <*****@*****.**> */ // Include domainservice require_once 'Transip/DomainService.php'; try { // obviously, there are several DNS entry types. these are defined in // the class constants for ease of use $dnsEntries[] = new Transip_DnsEntry('@', 86400, Transip_DnsEntry::TYPE_A, '80.69.67.46'); $dnsEntries[] = new Transip_DnsEntry('@', 86400, Transip_DnsEntry::TYPE_MX, '10 @'); $dnsEntries[] = new Transip_DnsEntry('@', 86400, Transip_DnsEntry::TYPE_MX, '20 relay.transip.nl.'); $dnsEntries[] = new Transip_DnsEntry('ftp', 86400, Transip_DnsEntry::TYPE_CNAME, '@'); $dnsEntries[] = new Transip_DnsEntry('mail', 86400, Transip_DnsEntry::TYPE_CNAME, '@'); $dnsEntries[] = new Transip_DnsEntry('www', 86400, Transip_DnsEntry::TYPE_CNAME, '@'); // you can now use the $dnsEntries array as the fourth parameter when instantiating // a new Transip_Domain. For example: $domain = new Transip_Domain('example.com', $nameservers = null, $contacts = null, $dnsEntries); Transip_DomainService::register($domain); echo 'The domain ' . $domain->name . ' has been requested.'; } catch (SoapFault $f) { // It is possible that an error occurs when connecting to the TransIP Soap API, // those errors will be thrown as a SoapFault exception. echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; }
/** * This example gets information about a list of domain names. * * @copyright Copyright 2011 TransIP BV * @author TransIP BV <*****@*****.**> */ require_once '../Transip/DomainService.php'; if (isset($_GET['domains']) && strlen($_GET['domains']) > 0) { /** @var string[] $domainNames A list of domain names. */ $domainNames = explode("\n", $_GET['domains']); $domainNames = array_filter($domainNames, 'trim'); try { // Request information about a domain in your account by using the TransIP // DomainService API; A domain Object will be returned holding all // information available about the domain. $domains = Transip_DomainService::batchGetInfo($domainNames); // INFO: A domain object holds all data directly available for a domain: // + it has a list of nameservers, // + a list of whois-contacts // + a list of dns-entries if the domain is using TransIP nameservers // + and, optionally, a Transip_DomainBranding object that holds // information about branding (see reseller info for more) // // The domain object does not include registrar-lock and auth/epp-code // information, since this information will always be fetched real-time // from the registry. To get this information, you can use the // getIsLocked() and getAuthCode API calls. $result = "We got the following information about these domains:\n" . htmlspecialchars(implode(",\n", $domainNames)) . "\n\n"; } catch (SoapFault $e) { // It is possible that an error occurs when connecting to the TransIP Soap API, // those errors will be thrown as a SoapFault exception.
<?php /** * This example sets the nameservers of a domain name. * * @copyright Copyright 2011 TransIP BV * @author TransIP BV <*****@*****.**> */ // Include domainservice require_once 'Transip/DomainService.php'; // Create the nameserver entries we want $nameservers = array(); $nameservers[] = new Transip_Nameserver('ns1.example.com'); $nameservers[] = new Transip_Nameserver('ns2.example.com', ''); // Since ns.thedomaintomodify.com is a subdomain of the domain we are saving, // the nameserver needs a glue record (ipv4 required, ipv6 optional) $nameservers[] = new Transip_Nameserver('ns.example.com', '99.99.99.99'); try { // Save the nameservers in the transip system Transip_DomainService::setNameservers('example.com', $nameservers); echo 'The nameservers have been saved.'; } catch (SoapFault $f) { // It is possible that an error occurs when connecting to the TransIP Soap API, // those errors will be thrown as a SoapFault exception. echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; }
<?php /** * This example checks the availability of one domain. * * @copyright Copyright 2011 TransIP BV * @author TransIP BV <*****@*****.**> */ require_once 'Transip/DomainService.php'; if (isset($_POST['domain']) && strlen($_POST['domain']) > 0) { $domain = $_POST['domain']; try { // Request the availability of a domain by using the Transip_DomainService API; // we can get the following different statusses back with different meanings. $availability = Transip_DomainService::checkAvailability($domain); switch ($availability) { case Transip_DomainService::AVAILABILITY_INYOURACCOUNT: $result = htmlspecialchars($domain) . ' is not available.'; break; case Transip_DomainService::AVAILABILITY_UNAVAILABLE: $result = htmlspecialchars($domain) . ' is not available for transfer.'; break; case Transip_DomainService::AVAILABILITY_FREE: $result = htmlspecialchars($domain) . ' is available for registration.'; break; case Transip_DomainService::AVAILABILITY_NOTFREE: $result = htmlspecialchars($domain) . ' is registered. If you are the owner, you could transfer it.'; break; } } catch (SoapFault $e) {
<?php /** * This example cancels a domain that is currently active in the users account. * * @copyright Copyright 2011 TransIP BV * @author TransIP BV <*****@*****.**> */ require_once 'Transip/DomainService.php'; if (isset($_POST['domain']) && strlen($_POST['domain']) > 0) { $domain = $_POST['domain']; $when = isset($_POST['when']) && !empty($_POST['when']) ? $_POST['when'] : 'end'; try { // Request cancellation of a domain by using the Transip_DomainService API; Transip_DomainService::cancel($domain, $when); } catch (SoapFault $e) { // It is possible that an error occurs when connecting to the TransIP Soap API, // those errors will be thrown as a SoapFault exception. $result = 'An error occurred: ' . htmlspecialchars($e->getMessage()); } } ?> <html> <head> </head> <body> <h2>TransIP API cancel Example</h2> Fill in the domain you want to cancel. <!-- cancelling is a modifying action, so we need to use POST instead of GET by the HTTP specs -->
$user->country = 'nl'; $user->phoneNumber = '0383783388'; $user->faxNumber = ''; $user->email = '*****@*****.**'; $users[] = $user; $result = true; try { // Request the availability of a domain by using the Transip_DomainService API; // we can get the following different statusses back with different meanings. $availability = Transip_DomainService::checkAvailability($domain); switch ($availability) { case Transip_DomainService::AVAILABILITY_FREE: echo htmlspecialchars($domain) . ' is vrij voor registratie.<hr/>'; try { $register = new Transip_Domain($domain, $nameservers, $users); Transip_DomainService::register($register); } catch (SoapFault $f) { // It is possible that an error occurs when connecting to the TransIP Soap API, // those errors will be thrown as a SoapFault exception. echo 'An error occurred: ' . htmlspecialchars($f->getMessage()); $result = false; } break; default: echo htmlspecialchars($domain) . ' is niet beschikbaar. Registratie afgebroken.'; $result = false; break; } } catch (SoapFault $e) { // It is possible that an error occurs when connecting to the TransIP Soap API, // those errors will be thrown as a SoapFault exception.
<?php /** * This example gets information about a domain name. * * @copyright Copyright 2011 TransIP BV * @author TransIP BV <*****@*****.**> */ require_once 'Transip/DomainService.php'; if (isset($_GET['domain']) && strlen($_GET['domain']) > 0) { $domainName = $_GET['domain']; try { // Request information about a domain in your account by using the TransIP // DomainService API; A domain Object will be returned holding all // information available about the domain. $domain = Transip_DomainService::getInfo($domainName); // INFO: A domain object holds all data directly available for a domain: // + it has a list of nameservers, // + a list of whois-contacts // + a list of dns-entries if the domain is using TransIP nameservers // + and, optionally, a Transip_DomainBranding object that holds // information about branding (see reseller info for more) // // The domain object does not include registrar-lock and auth/epp-code // information, since this information will always be fetched real-time // from the registry. To get this information, you can use the // getIsLocked() and getAuthCode API calls. $result = 'We got the following information about the domain ' . htmlspecialchars($domainName) . ':'; } catch (SoapFault $e) { // It is possible that an error occurs when connecting to the TransIP Soap API, // those errors will be thrown as a SoapFault exception.
/** * * * @param array $params * * @return array */ function transip_GetEPPCode($params) { transip_initialize($params); $domainName = $params['sld'] . "." . $params['tld']; $authCode = array("eppcode" => Transip_DomainService::getauthcode($domainName)); logModuleCall("transip", "GetEPPCode", $domainName, $authCode); return $authCode; }
*/ require_once 'Transip/DomainService.php'; if (isset($_REQUEST['domain']) && strlen($_REQUEST['domain']) > 0) { $domain = $_REQUEST['domain']; try { // Check to see if we an action was requested and if so, do it if (isset($_POST['lock'])) { // Lock the domain by using the Transip_DomainService API; $isLocked = Transip_DomainService::setLock($domain); } if (isset($_POST['unlock'])) { // Unlock the domain by using the Transip_DomainService API; $isLocked = Transip_DomainService::unsetLock($domain); } // Request the locked status of a domain by using the Transip_DomainService API; $isLocked = Transip_DomainService::getIsLocked($domain); } catch (SoapFault $e) { // It is possible that an error occurs when connecting to the TransIP Soap API, // those errors will be thrown as a SoapFault exception. $whois = 'An error occurred: ' . htmlspecialchars($e->getMessage()); } } else { $domain = ''; $isLocked = false; } ?> <html> <head> </head> <body>
<?php /** * This example gets information about a domain name. * * @copyright Copyright 2011 TransIP BV * @author TransIP BV <*****@*****.**> */ // Include domainservice require_once 'Transip/DomainService.php'; // Set the result variable $domainList = array(); try { // Call the API, the result will be an array of all your domain names $domainList = Transip_DomainService::getDomainNames(); // Output the domain names print_r($domainList); } catch (SoapFault $e) { // It is possible that an error occurs when connecting to the TransIP Soap API, // those errors will be thrown as a SoapFault exception. echo 'An error occurred: ' . $e->getMessage(), PHP_EOL; }
if ($currentDomainAction->hasFailed !== true) { // There is currently an action running, and it has not failed yet. $result = "Current action for domain is {$currentDomainAction->name}\n"; } else { // There was an action running on the domain, and it has failed. // We retry with new nameservers for the domain. $result = "Current action for domain is {$currentDomainAction->name} and has failed with message {$currentDomainAction->message}\n"; $result .= "Retrying....\n"; $domain = Transip_DomainService::getInfo($domainName); // Create new nameserver entries we want $nameservers = array(); $nameservers[] = new Transip_Nameserver('ns1.mydomain.com'); $nameservers[] = new Transip_Nameserver('ns2.mydomain.com', ''); // Since ns.thedomaintomodify.com is a subdomain of the domain we are saving, // the nameserver needs a glue record (ipv4 required, ipv6 optional) $nameservers[] = new Transip_Nameserver('ns.thedomaintomodify.com', '99.99.99.99'); $domain->nameServers = $nameServers; // We try the current action again, but now with our modified Transip_Domain object. // Based on the error message one should modify the appropiate part of this object Transip_DomainService::retryCurrentDomainActionWithNewData($domain); // If you need to change the authcode, please use the call below // Transip_DomainService::retryTransferWithDifferentAuthCode($domain, $newAuthCode); // If you want to cancel the action use // Beware, all changes will be rollbacked. // TransIP_DomainService::cancelDomainAction($domain) } echo $result; } catch (Exception $exception) { // When something goes wrong, an Exception will be thrown with relevant information. echo "An Exception occured. Code: {$exception->getCode()}, message: {$exception->getMessage()}\n"; }
<?php /** * This example gets information about the Tlds that * can be registered or transfered. * * @copyright Copyright 2011 TransIP BV * @author TransIP BV <*****@*****.**> */ // Include domainservice require_once 'Transip/DomainService.php'; try { // Call the API, the result will be an array of all Tlds $tldList = Transip_DomainService::getAllTldInfos(); // Output the Tlds print_r($tldList); } catch (SoapFault $f) { // It is possible that an error occurs when connecting to the TransIP Soap API, // those errors will be thrown as a SoapFault exception. echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; }
* This example checks a batch of domain names for availability information * and shows the result. * * @copyright Copyright 2011 TransIP BV * @author TransIP BV <*****@*****.**> */ require_once '../Transip/DomainService.php'; if (isset($_GET['domains']) && strlen($_GET['domains']) > 0) { // seperate each line into a domain and trim off any whitespace $domains = explode("\n", $_GET['domains']); $domains = array_map('trim', $domains); $result = ''; try { // Request the availability of multiple domains by using the Transip_DomainService API; // we can get the following different statusses back with different meanings, wrapped in a Transip_DomainCheckResult. $domainCheckResults = Transip_DomainService::batchCheckAvailability($domains); foreach ($domainCheckResults as $domainCheckResult) { switch ($domainCheckResult->status) { case Transip_DomainService::AVAILABILITY_INYOURACCOUNT: $result .= htmlspecialchars($domainCheckResult->domainName) . ' is not available.<br/>'; break; case Transip_DomainService::AVAILABILITY_UNAVAILABLE: $result .= htmlspecialchars($domainCheckResult->domainName) . ' is not available for transfer.<br/>'; break; case Transip_DomainService::AVAILABILITY_FREE: $result .= htmlspecialchars($domainCheckResult->domainName) . ' is available for registration.<br/>'; break; case Transip_DomainService::AVAILABILITY_NOTFREE: $result .= htmlspecialchars($domainCheckResult->domainName) . ' is registered. If you are the owner, you could transfer it.<br/>'; break;
<?php /** * This example changes the dns entries of a domain. * * @copyright Copyright 2011 TransIP BV * @author TransIP BV <*****@*****.**> */ // Include domainservice require_once 'Transip/DomainService.php'; // Create the dns entries we want $dnsEntries = array(); $dnsEntries[] = new Transip_DnsEntry('@', 86400, Transip_DnsEntry::TYPE_A, '127.0.0.1'); $dnsEntries[] = new Transip_DnsEntry('www', 86400, Transip_DnsEntry::TYPE_CNAME, '@'); $dnsEntries[] = new Transip_DnsEntry('mail', 86400, Transip_DnsEntry::TYPE_CNAME, '@'); $dnsEntries[] = new Transip_DnsEntry('@', 86400, Transip_DnsEntry::TYPE_MX, '10 mail.'); try { // Save the dns entries in the transip system Transip_DomainService::setDnsEntries('example.com', $dnsEntries); echo 'The DNS Entries have been saved.'; } catch (SoapFault $f) { // It is possible that an error occurs when connecting to the TransIP Soap API, // those errors will be thrown as a SoapFault exception. echo 'An error occurred: ' . $f->getMessage(), PHP_EOL; }
<?php /** * This example gets and shows the WHOIS information for a domain. * * @copyright Copyright 2011 TransIP BV * @author TransIP BV <*****@*****.**> */ require_once 'Transip/DomainService.php'; if (isset($_GET['domain']) && strlen($_GET['domain']) > 0) { $domain = $_GET['domain']; try { // Request the WHOIS information of a domain by using the Transip_DomainService API. $whois = Transip_DomainService::getWhois($domain); } catch (SoapFault $e) { // It is possible that an error occurs when connecting to the TransIP Soap API, // those errors will be thrown as a SoapFault exception. $whois = 'An error occurred: ' . htmlspecialchars($e->getMessage()); } } else { $domain = ''; $whois = ''; } ?> <html> <head> </head> <body> <h2>TransIP API Whois Example</h2> Fill in the domain you want to get the whois for and click on Get Whois.