Here is a template to use for the API. This is very similar to the enom api.
If you have any questions at all let me know.
To make it work upload the file to the tldmodules folder and name it the same as the class name. It will show up in the Tld section of the admin panel.
PHP Code:
<?php
class domaintemplate{
var $host;
var $username;
var $password;
var $nameserver1;
var $nameserver2;
var $serverid;
var $PackageInformation = array();
var $ClientInformation = array();
var $DomainRegistrantInformation = array();
var $sld;
var $tld;
function __construct(){
}
function ServerOptions(){
$options = array(
array('formtype' => 'text', 'description' => LANG_USERNAME, 'name' => 'username', 'value' => ''),
array('formtype' => 'text', 'description' => LANG_PASSWORD, 'name' => 'password', 'value' => ''),
array('formtype' => 'text', 'description' => 'NameServer 1', 'name' => 'nameserver1', 'value' => 'ns1.yourdomain.com'),
array('formtype' => 'text', 'description' => 'NameServer 2', 'name' => 'nameserver2', 'value' => 'ns2.yourdomain.com'),
array('formtype' => 'text', 'description' => 'API URL', 'name' => 'url', 'value' => 'api.url'),
);
return $options;
}
function TldOptions(){
$tlds = array('com' => 'com', 'net' => 'net', 'org' => 'org', 'biz' => 'biz', 'info' => 'info', 'us' => 'us');
$options = array(
array('formtype' => 'select', 'description' => 'TLD', 'name' => 'tld',
'value' => $tlds
),
);
return $options;
}
function SetServerInformation($data){
$this->host = $data['NIXBILL'][0]['RESULT'][0]['OPTIONS'][0]['SERVER_URL'][0]['VALUE'];
$this->serverid = $data['NIXBILL'][0]['RESULT'][0]['SERVERID'][0]['VALUE'];
$this->username = $data['NIXBILL'][0]['RESULT'][0]['OPTIONS'][0]['SERVER_USERNAME'][0]['VALUE'];
$this->password = $data['NIXBILL'][0]['RESULT'][0]['OPTIONS'][0]['SERVER_PASSWORD'][0]['VALUE'];
$this->ns1 = $data['NIXBILL'][0]['RESULT'][0]['OPTIONS'][0]['SERVER_NAMESERVER1'][0]['VALUE'];
$this->ns2 = $data['NIXBILL'][0]['RESULT'][0]['OPTIONS'][0]['SERVER_NAMESERVER2'][0]['VALUE'];
}
function SetPackageOptions($data){
$this->PackageInformation = $data;
}
function SetClientInformation($data){
$this->ClientInformation = $data;
}
function SetDomainRegistrantInformation($data){
$this->DomainRegistrantInformation = $data;
}
function SetSLD($sld){
$this->sld = $sld;
}
function SetTLD($tld){
$this->tld = $tld;
}
function register(){
$years = $this->Years($this->PackageInformation['cycle']);
$c = new Curl('get');
$c->SetUrl($this->host);
$c->AddField('Command','Purchase');
$c->AddField('UID',$this->username);
$c->AddField('PW',$this->password);
$c->AddField('SLD',$this->PackageInformation['sld']);
$c->AddField('TLD',$this->PackageInformation['tld']);
$c->AddField('NumYears',$years);
$c->AddField('NS1',$this->ns1);
$c->AddField('NS2',$this->ns2);
$c->AddField('RegistrantFirstName',$this->DomainRegistrantInformation['fname']);
$c->AddField('RegistrantLastName',$this->DomainRegistrantInformation['lname']);
$c->AddField('RegistrantAddress1',$this->DomainRegistrantInformation['address1']);
$c->AddField('RegistrantCity',$this->DomainRegistrantInformation['city']);
$c->AddField('RegistrantStateProvince',$this->DomainRegistrantInformation['state']);
if($this->DomainRegistrantInformation['country'] == 'USA'){
$c->AddField('RegistrantStateProvinceChoice','S');
}
$c->AddField('RegistrantPostalCode',$this->DomainRegistrantInformation['zipcode']);
$c->AddField('RegistrantCountry',$this->DomainRegistrantInformation['country']);
$c->AddField('RegistrantPhone','+1.'.$this->DomainRegistrantInformation['phone1']);
$c->AddField('RegistrantFax','+1.'.$this->DomainRegistrantInformation['fax']);
$c->AddField('RegistrantEmailAddress',$this->DomainRegistrantInformation['email']);
if($this->DomainRegistrantInformation['us_nexus']){
$c->AddField('us_nexus',$this->DomainRegistrantInformation['us_nexus']);
}
if($this->DomainRegistrantInformation['us_purpose']){
$c->AddField('us_purpose',$this->DomainRegistrantInformation['us_purpose']);
}
if($this->DomainRegistrantInformation['uk_legal_type']){
$c->AddField('uk_legal_type',$this->DomainRegistrantInformation['uk_legal_type']);
}
if($this->DomainRegistrantInformation['registered_for']){
$c->AddField('registered_for',$this->DomainRegistrantInformation['registered_for']);
}
$c->AddField('ResponseType','XML');
$result = $c->Process();
$this->logcall('register '.$this->PackageInformation['sld'].'.'.$this->PackageInformation['tld'], $c->GetString(), $result);
$return = $this->FormatReturn($result);
/**
* The status is needed here to know if the domain was registered correctly.
*/
if($domainstatus == true){ //the $domainstatus needs to be evaluated by the return value from the registrar
$output = array(
'status' => '1', /// status 1 shows the process completed correctly
'orderid' => $orderid , /// the $orderid will come from the registrar. this is for record keeping only, not required
'statusmessage' => $statusmessage /// $statusmessage is what will be displayed on the status
);
}else{
$output = array(
'status' => '0',
'error' => '1',
'statusmessage' => $statusmessage /// $statusmessage is what will be displayed on the status
);
}
return $output;
//return $result;
}
function renew(){
$years = $this->Years($this->PackageInformation['cycle']);
$c = new Curl('get');
$c->SetUrl($this->host);
$c->AddField('Command','Extend');
$c->AddField('UID',$this->username);
$c->AddField('PW',$this->password);
$c->AddField('SLD',$this->PackageInformation['sld']);
$c->AddField('TLD',$this->PackageInformation['tld']);
$c->AddField('NumYears',$years);
$c->AddField('ResponseType','XML');
$result = $c->Process();
$this->logcall('renew', $c->GetString(), $result);
$return = $this->FormatReturn($result);
/**
* The status is needed here to know if the domain was registered correctly.
*/
if($domainstatus == true){ //the $domainstatus needs to be evaluated by the return value from the registrar
$output = array(
'status' => '1', /// status 1 shows the process completed correctly
'orderid' => $orderid , /// the $orderid will come from the registrar. this is for record keeping only, not required
'statusmessage' => $statusmessage /// $statusmessage is what will be displayed on the status
);
}else{
$output = array(
'status' => '0',
'error' => '1',
'statusmessage' => $statusmessage /// $statusmessage is what will be displayed on the status
);
}
return $output;
}
function logcall($call, $request, $result){
mysql_query("INSERT INTO `hostingmodulelogs` (`call`, `request`, `result`, `serverid`)VALUES('".$call."', '".$request."', '".$result."', '".$this->serverid."')");
}
function FormatReturn($data){
$xml = new XML();
$array = $xml->processXML($data);
return $array;
}
function Years($cycle){
$cycleToYears[6] = 1;
$cycleToYears[7] = 2;
$cycleToYears[8] = 3;
$cycleToYears[9] = 4;
$cycleToYears[10] = 5;
$cycleToYears[11] = 6;
$cycleToYears[12] = 7;
$cycleToYears[13] = 8;
$cycleToYears[14] = 9;
$cycleToYears[15] = 10;
$years = $cycleToYears[$cycle];
return $years;
}
}
?>