Directi API Integration: Checking Domain Availability - checkAvailability

| | 2 min read

Directi is one of the largest domain registrars on the internet with their services such as ResellerClub, and they provide wonderfully complete to-go solutions for resellers. But there are times when you would want to build upon their platforms rather than just use their entire solution. For this, they provide you the Directi API. You can build upon these as you wish to build out customized solutions of your own.

One of the first steps in registering a domain is checking the availability of the domain name you are interested in. DirectI API provides the checkAvailability function for this.

function:
AssociativeArray checkAvailability (string $userName, string $password, string $role, string $langpref, int $parentid, string $domainName, boolean $suggestAlternative)

Inputs:
string $userName: Username.
string $password: Password.
string $role: Role.
string $langpref: Language Preference.
int $parentid: Parent id.
string $domainName: The domainname
for which availability is to be checked boolean $suggestAlternative: If this parameter is true, then availability will be checked for all supported TLD's. If it is false, then availability will be checked only for the specified TLD.

Returns:
AssociativeArray AssociativeArray has the domainname as the key and a AssociativeArray as the value. The inner AssociativeArray has two keys - status and classkey

 {atestdomain.com={status=regthroughothers, classkey=domcno}}

Possible values for the status are: available, regthroughus and regthroughothers. The classkey denotes the TLD type of the domainname.

define('DIRECTI_USER', $directi_username);
define(DIRECTI_PASSWORD', $directi_password);
define('DIRECTI_LANG', 'en');
define('DIRECTI_PARENTID', $directi_parent_id);
define('DIRECTI_ROLE', “reseller”);
define('SERVICE_URL,'http://soapapi.com/anacreon/servlet/APIv3')

/**
* Functions for check availabilty of an domain
*/
function check_domainavailability($domain, $tld) {
 $DEBUG = TRUE;
 define('C_DEBUG', $DEBUG);
 $username =  DIRECTI_USER;
 $password =  DIRECTI_PASSWORD;
 $langpref = DIRECTI_LANG;
 $parentid =  DIRECTI_PARENTID;
 $role = DIRECTI_ROLE;
 $domain = $_POST['domain'];

 $domain_name = explode('.',$domain);
 $arr_domains= array($domain_name);
 $available_extensions = array('com', 'us', 'net', 'org', 'biz', 'info', 'ws');
 $serviceObj = new DomOrder(path to DomOrder.wsdl lib file);
 $obj_available_domain =
   $serviceObj->checkAvailabilityMultiple($username, $password, $role,
 $langpref, $parentid, $arr_domains, $available_extensions, TRUE);
//  $obj_available_domain  variable return an array of available and unavailable domains.
}