Reseller Club PHP API Integration

domain_sxc_49702_3823-300x225 I want my clients to be able to check for domain names and register them from my site. As a member of the Reseller Club I can do just that… once I figure out their API. They do have some documentation on the site, but it took quite a bit of work to figure out exactly how things should work. A lot of the documentation is for the SOAP implementation which they have phased out (or will soon). I want to use the HTTP API. Much of the downloadable documentation was for SOAP and was horribly outdated, so I decided to write this post for those of you, like me, who need more examples and better documentation.

Most of you are probably a lot smarter than me and may not need what I’m going to share, but then again, if it helps someone to get it working more quickly, then it’s been worth my time. I found their documentation a little lacking and hard to follow. Once I figured out the difference in the test site and the live site and how I can use CURL in PHP to integrate my site with the API, the documentation made more sense.

The documentation for the HTTP API kept telling me to download the PHP kit but then it would link to the SOAP API PHP kit which was confusing. There was no PHP kit that I could find for the HTTP API. Somehow I finally got it to work without the examples. Trial and error finally paid off.

First you need to set your IP address in your reseller account. You can do this in your Settings->API. This allows your website scripts to use the API to call the test and live reseller API’s. This takes a while to resolve so you may want to do this a day or so before you need to work on your integration.

To test your integration, you will need a demo reseller account. You will need to use your username and password for the demo account when testing along with the different URL for the test account – https://test.httpapi.com. When you are ready to use your scripts for real on the live server, you will have to change the username, password and URL to the live account information. The url for the live site is https://httpapi.

Pay attention to which method you use in CURL. Some API’s use GET while others require POST. When I was checking for domain availability, the test url would let me use POST but the live url required GET. I also found it confusing at first that the domains I checked in the test site came back available. Apparently, the domains in the test system are not updated with the live system. In other words, when I checked the availability of a domain that I KNEW was already registered, it came back as available. That’s because the domain was not registered in the test system. Checking the same domain in the live system gave me different, but expected, results.

To make all this more clear, I want to show you the exact code that I’m using to make all this work. I’ll use the domain availability API first to show you how it works in test mode:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://test.httpapi.com/api/domains/available.json?auth-userid=123456&auth-password=password&domain-name=mydomainname&tlds=com&tlds=net");
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$httpResponse = curl_exec($ch);
print_r($httpResponse);

This code gives the following response:

{"mydomainname.net":{"status":"regthroughothers","classkey":"dotnet"},"mydomainname.com":{"status":"regthroughothers","classkey":"domcno"}}

When I’m ready to use this in live mode, I just change the url to https://httpapi.com and change the username and password in the url as well like so:


curl_setopt($ch, CURLOPT_URL, "https://httpapi.com/api/domains/available.json?auth-userid=654321&auth-password=live-password&domain-name=mydomainname&tlds=com&tlds=net");

If you need to use an API call which will change or destroy data you will need to use the POST method in CURL instead of the GET method.


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://test.httpapi.com/api/domains/register.json");
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

curl_setopt($ch, CURLOPT_POST,TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// Set the request as a POST FIELD for curl.
curl_setopt($ch, CURLOPT_POSTFIELDS, 'auth-userid=123456&auth-password=password&domain-name=domain1.net&years=1&ns=ns1.domain.com&ns=ns2.domain.com&customer-id=382718®-contact-id=2558879&admin-contact-id=2558739&tech-contact-id=2558839&billing-contact-id=2558839&invoice-option=KeepInvoice&protect-privacy=false');
$httpResponse = curl_exec($ch);
print($httpResponse);

This will register the domain name in the test account. To register a domain in the live account I would need to change the url, username and password as I did previously.

Hopefully this will help save you a little time as you integrate your resellerclub API into your website.

photo credit: The Booklight via photopin cc

61 thoughts on “Reseller Club PHP API Integration”

  1. Hi,

    it helped me a lot in integraton of API. thank you very much for sharing the problems you faced during integration. Respect !!

    Rahul

  2. Thanks bro i was searching it from many days ….. you saved me…… could you tell me how we get the status part only so that we will show it to our customers. like only :available or regthroughothers.

    1. I didn’t find any complete scripts. I found resellerclub to be cheaper than enom on domain names, so it’s worth writing it from scratch for me.

      1. I want to sell resellerclub domains, webshoting, ssl etc from my custom made website, but do not know how to integrate the resellerclub api to my website. could you suggest me something? currently i am selling these products from supersite with domain name http://advisehost.net.

  3. How resellerclub api works with wordpress. I have existing website with wordpress platform and I want to integrate api into it. Please help.

    1. It should work the same way with WordPress. You should put the api code in the functions.php file of your theme or you could build a plugin for the code.

      1. Can you please help me with the same. How I will do that. Will you help me with any example or website that is using resellerclub api.

          1. i tried the APi already on wordpress. its a bid failure.
            since wrdpress has its own database to manage itself, annd when you use the API, it loops itself.
            Not sure how.

  4. Can you please help me with the same. How I will do that. Will you help me with any example or website that is using resellerclub api.

  5. Thanks for the great tutorial and helping me get started. Quick question, when I change the reg-contact-id, admin-contact-id, tech-contact-id etc., to a demo customer I created, I receive an error response, “ContactId is not registered by you, registrant ContactId is not registered by you…” etc., Any idea what I am supposed to use here? I have tried my auth-id and the customer id and both get the error.

    1. I would make sure that you are using the correct account that has the customer. If you created the customer in your demo account, make sure you are using that URL in the code. If you created the customer in your live account, make sure that’s the URL in the code. That’s my guess.

  6. My guess is that you are accessing the live site vs. the test site. The test site will give different results.

  7. I tried this but I am getting a strange response.

    {“status”:”ERROR”,”message”:”An unexpected error has occurred”}

    🙁

    1. I think I got this error when I had my password wrong or was sending the wrong username and password to the test server, or vice versa. I would check the endpoint URL to make sure you are going to the correct server (test or production) and then make sure you have the correct username and password for that server.

      Hope that helps!

  8. Hi Cindy

    Have successfully implemented HTTP API using
    $data = json_decode(file_get_contents($url));

    done up till receiving data from test server.

    {“mydomainname.net”:{“status”:”regthroughothers”,”classkey”:”dotnet”},”mydomainname.com”:{“status”:”regthroughothers”,”classkey”:”domcno”}}

    But the problem is i am newbie to json so i am not able the parse this json array though i followed some json tuts but no success and so not able to display it in the real HTML site

    Can you give me example implementation of received data.

    Thanks in Advance.
    Nawaz

  9. contact-id=2558879&admin-contact-id=2558739&tech-contact-id=2558839&billing-contact-id=2558839

    how you get these infos ?

    because of this I cant follow
    http://cp.onlyfordemo.net/kb/answer/874
    This link says only user-id / api/customer-email

    but the o/p returns
    {“status”:”ERROR”,”message”:”Required parameter missing: contact-id”}

    Donno where this contact-id comes from

    regards
    Shylesh

    1. The contact id is the user’s id. You will have to get that from the customer’s record – or keep it in your database when the customer signs up.

      1. Oh ok.

        Thank you.
        I was wondering from where you can extract this.
        So for now, I have to pick this value manually, henceforth save in database.

  10. Hi Cindy,

    Are you aware how in php i can accept data into variable from an array output

    eg
    single parameter check
    {“status”:”ERROR”,”message”:”An unexpected error has occurred”}

    double parameter check
    {{“status”:”ERROR”,”message”:”An unexpected error has occurred”},{“status”:”ERROR”,”message”:”An unexpected error has occurred”}}

    and so on…

    I have to somehow catch the 2nd element into a variable dynamically.

  11. hello guys i have some realy serious problem for long time
    i created 5 customer in my demo account
    and take their customer id and give it to them
    customer-id=10963193 (customer 1 customer id)
    reg-contact-id=10966318 (customer 2 customer id)
    admin-contact-id=10966307 (customer 3 customer id)
    tech-contact-id=10963860 (customer 4 customer id)
    billing-contact-id=10966320 (customer 5 customer id)

    but when i pass it it gives a error

    {“status”:”ERROR”,”message”:”{techcontactidu003dtech ContactId is not registered by you, admincontactidu003dadmin ContactId is not registered by you, billingcontactidu003dbilling ContactId is not registered by you, registrantcontactidu003dregistrant ContactId is not registered by you}”}

    can any one please help its realy very important

  12. hello Cindy i have some realy serious problem for long time
    i created 5 customer in my demo account
    and take their customer id and give it to them
    customer-id=10963193 (customer 1 customer id)
    reg-contact-id=10966318 (customer 2 customer id)
    admin-contact-id=10966307 (customer 3 customer id)
    tech-contact-id=10963860 (customer 4 customer id)
    billing-contact-id=10966320 (customer 5 customer id)

    $userid= “519473”;
    $apikey= “ZNmID1ypHfDQ61YKQw0GufQQ2k3HxR0Y”;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, “https://test.httpapi.com/api/domains/register.json”);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_POST,TRUE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    // Set the request as a POST FIELD for curl.
    curl_setopt($ch, CURLOPT_POSTFIELDS, ‘auth-userid=519473&api-key=ZNmID1ypHfDQ61YKQw0GufQQ2k3HxR0Y&domain-name=hts.in&years=1&ns=ns1.faizan.com&ns=ns2.faizan.com&customer-id=10963193&reg-contact-id=10966318&admin-contact-id=10966307&tech-contact-id=10963860&billing-contact-id=10966320&invoice-option=NoInvoice&protect-privacy=false’);
    $httpResponse = curl_exec($ch);
    print($httpResponse);

    but when i pass it it gives a error

    {“status”:”ERROR”,”message”:”{techcontactidu003dtech ContactId is not registered by you, admincontactidu003dadmin ContactId is not registered by you, billingcontactidu003dbilling ContactId is not registered by you, registrantcontactidu003dregistrant ContactId is not registered by you}”}

    please help its realy very important

    1. My first guess is that you created them in the demo account and are trying to access them in your live account? Or a different account?

      1. created it in demo account
        with reseller id or auth-userid=519473
        like i used test.httpapi url
        and i also create customer under this account

          1. can u please tel me
            customer-id,reg-contact-id,admin-contact-id,tech-contact-id,billing-contact-id
            these should be the customer ids of the diffrent customers that i created in my accout?

      2. i also create a new account and create customers in that resseller account but i also get the same problem .. 🙁

  13. Hi,
    I am using this api with my test resellerclub account. I added my ip in whitelist ip addresses but I get the below error:
    “{“status”:”ERROR”,”message”:”Access Denied: You are not authorized to perform this action”}”
    I need your help.

    1. I would double check your endpoint URL. Make sure you are using the correct endpoint for testing or the live site. Also, check to make sure you are using the correct password for the endpoint URL you are using.

  14. Hi cindy,

    Thank you for helping newbie developers around the globe.
    I was trying to implement your tutorial and am running into some issues. Would it be possible for you to send me the full code with the form etc so as to complete my project using it.
    Truly Appreciate your help

    1. I don’t have the code with me at the moment but will try to post it when I get back to my office. Until then, you can just create a standard html form sending post variables and then transfer the $_POST[‘field’] variables to the php variables such as: $email = $_POST[’email’] Everything else is here in this blog post.

  15. Hi,
    my setup was working fine in the test mode and made the site to register through api, what are the steps to be taken to make it in the live mode using API.

    1. Srinivasan, make sure that you’ve followed these steps:

      “First you need to set your IP address in your reseller account. You can do this in your Settings->API. This allows your website scripts to use the API to call the test and live reseller API’s. This takes a while to resolve so you may want to do this a day or so before you need to work on your integration.”

      “When you are ready to use your scripts for real on the live server, you will have to change the username, password and URL to the live account information. The url for the live site is https://httpapi.”

      This may have changed since I originally wrote this post. I haven’t kept up with it, so check the documentation and let me know if it’s changed so I can update the post. I will do this myself when I get a little extra time.

  16. plz plz help me i got this error msg

    [message] => {techcontactid=tech ContactId is not registered by you, admincontactid=admin ContactId is not registered by you, billingcontactid=billing ContactId is not registered by you, registrantcontactid=registrant ContactId is not registered by you}

    i am using testing link on demo site https://test.httpapi.com/api/domains/register.json for domain registraion

    i have register customer but dont understand what i pass in following parameters
    reg-contact-id=42788&
    admin-contact-id=42788&
    tech-contact-id=42788&
    billing-contact-id=42788&

    i have test with add custom and reseller suer and assign them support, sales and billing option and pass their ids but still got same error

  17. Hi,

    I Want to get all domains details by Reseller id, Is there any way to fetch all orders from reseller account.

    1. I’m not sure I understand your question. You can access the reseller club API from WordPress if that’s what you are asking.

  18. I was curios to learn if you had success with just accessing the mail control panel as shown here: http://manage.resellerclub.com/kb/answer/954

    I am badly stuck with the auth-token and order-id parameters that need to be added. I did however go as far as collecting the auth-token , but I dont know how to take that value and programmatically use to finally reach the email control panel.

    The intention is NOT to login to a complicated control panel, just have the clients visit their email portal to change names, add/remove emails and see their email quota across the board.

    Any help would be appreciated.

  19. hi, can you help me? i get this error when i try to register domain. someone says “it’s because tld extension” but i had try all of tld extension and all of them get this error also.

    Array
    (
    [status] => error
    [error] => Invalid domainName For Given ContactType
    )

    i hope you can solve my case. thanks before 🙂

  20. Hi,

    I am trying to integrate the reseller API for registering a domain for a customer under my reseller account. As far as I worked, I am able to check the domain availability, Suggest Names, Create Customer under seller.

    However, I am not able to work with registering a domain for the customer, since it is asking for reg-contact-id, admin-contact-id, tech-contact-id and billing-contact-id as required params and I am not able to find where to generate or get these IDs from the API.

    Could you please help us to find out where to get these IDs from API.

    Thanks in advance.

  21. $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, “https://test.httpapi.com/api/domains/available.json?auth-userid=my_id &auth-password=My_api&domain-name=testdomainrani&tlds=com&tlds=net”);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $httpResponse = curl_exec($ch);
    print_r($httpResponse);

    This code gives the following response:

    Localhost

    {“status”:”ERROR”,”message”:”Required authentication parameter missing”}

  22. Double check your auth-userid and auth-password with those from reseller club and make sure they are correct. Also, check with the documentation at reseller club since this is an old post. I haven’t updated this with any updates from their API.

    1. test.httpapi.com/api/domains/available.json?auth-userid=688032&api-key=cCMOoDqw96yGNWyZGTkJLKKtAqDPfGyL&domain-name=testadminindia&domain-name=testadminindiatamilnadu&tlds=com&tlds=net

      This code gives the following response:

      {“status”:”ERROR”,”message”:”Required authentication parameter missing”}

  23. Issue in declaring domain-name in the domain availability checker API

    When I declare domain name dynamically as given below I’m getting error as “undefined domain-name”.

    public function test(Request $request)
    {
    $domainname = $request->get(‘domain-name’);
    $tld = $request->get(‘tlds’);
    $response = file_get_contents(‘https://httpapi.com/api/domains/available.json?auth-userid=711757&api-key=74miSZPgYkkc108Ptmeo5Q8iDTtKk3xi&domain-name=’.$domainname.’&tlds=’.$tld.”);
    }

    return view(‘clientlayout.main.tld’,compact(‘response’));

  24. Issue in declaring domain-name in the domain availability checker API…

    When I declare domain name dynamically as given below I’m getting error as “undefined domain-name”.

    public function test(Request $request)
    {
    $domainname = $request->get(‘domain-name’);
    $tld = $request->get(‘tlds’);
    $response = file_get_contents(‘https://httpapi.com/api/domains/available.json?auth-userid=711757&api-key=74miSZPgYkkc108Ptmeo5Q8iDTtKk3xi&domain-name=’.$domainname.’&tlds=’.$tld.”);
    }

    return view(‘clientlayout.main.tld’,compact(‘response’));

    1. I suggest printing out the value in $request->get(‘domain-name’) to see if it’s what you expect. Also print out exactly what you are sending to file_get_contents. I suspect that the value coming in may already have the tld attached so you may be getting something like ‘domain.com.com’ in the url.

    1. Amiya, Generally you set the prices on the page of your site since the owner of the site can sell the domains for any price they desire. I’m not aware of a way to access the price from the API, but I’ve never tried to find that either.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top