Jump to content

Whmcs Custom Cloudns Registrar Module


Recommended Posts

Hi,

 

Im trying to integrate cloudns on whmcs.

 

So here is the process I want to achieve.

Suppose I have these dns zones on cloudns:

1. concert.ph

2. show.ph

3. artist.ph

 

And on whmcs

I have this subdomain :

1. paul.concert.ph

 

This subdomain will add a new NS record under concert.ph zone on cloudns like :

paul.concert.ph NS ns1.test.com

 

And that NS record can be edited on whmcs and will be reflected on cloudns.

 

=====================================================

 

And my Custom Whmcs Cloudns Module code is :

<?php

function cloudns_getConfigArray() {
$configarray = array(
 "AuthID" => array( "Type" => "text", "Size" => "20", "Description" => "Enter your API ID here", ),
 "AuthPass" => array( "Type" => "password", "Size" => "20", "Description" => "Enter your API Password here", ),
);
return $configarray;
}

function apiCall($url, $data, $params) { 
       $AI = $params["AuthID"];
$AP = $params["AuthPass"];

/*Test Match Whmcs param to cloudns api param*/

$authid = $AI;
$authpassword = $AP;

$url = 'https://api.cloudns.net/'. $url;

/*I want to use the match whmcs/cloudns params here*/
$data = '&auth-id='.$authid.'&auth-password='.$authpassword.'&'. $data;

$init = curl_init();
curl_setopt($init, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($init, CURLOPT_RETURNTRANSFER, true);
curl_setopt($init, CURLOPT_URL, $url);
curl_setopt($init, CURLOPT_POST, true);
curl_setopt($init, CURLOPT_POSTFIELDS, $data);

$content = curl_exec($init);

curl_close($init);

return json_decode($content, true);
}

function cloudns_GetNameservers($params) {

$tld = $params["tld"];
$sld = $params["sld"];

# Put your code to get the nameservers here and return the values below
$values["ns1"] = $nameserver1;
$values["ns2"] = $nameserver2;
       $values["ns3"] = $nameserver3;
       $values["ns4"] = $nameserver4;

$connect = apiCall('dns/add-record.json', 'domain-name=',$tld,'&record-type=',NS,'&host=',$sld,'&record=',$values["ns1"],'&ttl=',3600);
$connect = apiCall('dns/add-record.json', 'domain-name=',$tld,'&record-type=',NS,'&host=',$sld,'&record=',$values["ns2"],'&ttl=',3600);
$connect = apiCall('dns/add-record.json', 'domain-name=',$tld,'&record-type=',NS,'&host=',$sld,'&record=',$values["ns3"],'&ttl=',3600);
$connect = apiCall('dns/add-record.json', 'domain-name=',$tld,'&record-type=',NS,'&host=',$sld,'&record=',$values["ns4"],'&ttl=',3600);        


# If error, return the error message in the value below
if (isset($connect['status']) && $connect['status'] == 'Failed') {
	$values["error"] = $error;
}
return $values;
}


function cloudns_SaveNameservers($params) {
$tld = $params["tld"];
$sld = $params["sld"];
$nameserver1 = $params["ns1"];
$nameserver2 = $params["ns2"];
$nameserver3 = $params["ns3"];
$nameserver4 = $params["ns4"];

# Put your code to save the nameservers here	
$connect = apiCall('dns/mod-record.json', 'domain-name=',$tld,'&record-id=',1101257,'&host=',$sld,'&record=',$nameserver1,'&ttl=',3600);
$connect = apiCall('dns/mod-record.json', 'domain-name=',$tld,'&record-id=',1101257,'&host=',$sld,'&record=',$nameserver2,'&ttl=',3600);
$connect = apiCall('dns/mod-record.json', 'domain-name=',$tld,'&record-id=',1101257,'&host=',$sld,'&record=',$nameserver3,'&ttl=',3600);
$connect = apiCall('dns/mod-record.json', 'domain-name=',$tld,'&record-id=',1101257,'&host=',$sld,'&record=',$nameserver4,'&ttl=',3600);

# If error, return the error message in the value below
// This method returns array with Status and StatusDescription, the Statuses are Failed i Success
if (isset($connect['status']) && $connect['status'] == 'Failed') {
	$values["error"] = $error;
}
return $values;
}

?>

===================================================================================

 

Unfortunately there is no ns record added in cloudns but I have a successful saved ns on whmcs client area.

 

Please check my code if I miss something to make my custom module work.

Cloudns API can be found here : https://asia.cloudns.net/api-help/records/add-record-domain-zone/

 

Please advise. Many Thanks.

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated