Jump to content

WHMCS API get nameservers


Recommended Posts

Like explained http://docs.whmcs.com/API:Domain_Nameservers


I'm using the following code to get name servers.


$command = "domaingetnameservers";
$adminuser = "admin";
$values["domainid"] = "7";
$results = localAPI($command,$values,$adminuser);

echo $ns1.$ns2.$ns3.$ns4.$ns5;


And even $results is:

Array ( [result] => success [error] => )


I get every ns1, ns2... empty. How is that so?

Link to comment
Share on other sites

  • 1 year later...

First of all $ns1, $ns2, $ns3, $ns4 and $ns5 for sure are empty variables since everything come from $result like you can see below (it's an example).


Array ( [result] => success [ns1] => ns1.infinitycdn.com [ns2] => ns2.infinitycdn.com [ns3] => ns3.infinitycdn.com [ns4] => ns4.infinitycdn.com [ns5] => [error] => )


So you have to make it in this way:


$ns1 = $result["ns1"];
$ns2 = $result["ns2"];
$ns3 = $result["ns3"];
$ns4 = $result["ns4"];
$ns5 = $result["ns5"];


Now all your variables contain the nameserver. About your problem please verify that:


  • Domain ID 7 exists
  • Account "admin" exists on your WHMCS and has API access
  • Domain ID 7 has nameservers


I have an issue , for this code snippet. it doesn't return anything (localAPI), and page freezes white. Could you post anything if you got some tips?


The code posted by tatocaster works. Have you tryed it?

Link to comment
Share on other sites

yeah I know, I'm pretty well in PHP. I did to assign input array elements to new variables. Also there is written that - if you are calling localApi user is optional , but I'm using, different user. which is registered in system as Administrator. also about domainid, I'm taking this dynamically. I did everything what you wrote, but with no success , that's why , i'm posting here. Because of this, I rewrote this functions with my custom queries to select, update db and etc. Can you give me a other clue? Thanks for response

Link to comment
Share on other sites

Join the conversation

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

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