Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Dec 2010
    Posts
    31

    Question How to get the main domain name of account from cPanel API [thro' 2082/2083 port]?

    Hi,

    I need a help. I am not able to find the API for getting the main domain name of a cPanel account. I would like to know if there is any cPanel API call similar to WHM's listacct function.

    I will have only the cPanel username & password and using this authentication I should call the API thro' 2082/2083 port and get the main domain of the account.

    Is that possible?

    Many thanks,
    Nesan Joseph R.

  2. #2
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    525

    Default Re: How to get the main domain name of account from cPanel API [thro' 2082/2083 port]

    Hi Nesan,

    There's not a 'clean' API call for what you need. However, there's a unique way that you can get user variables, like the primary domain, for remote calls.

    Remote calls use the XML-API. There's a special API1 module called 'print' that will allow you access to the cPanel user's variables. When making the XML-API call you will want to pass the following values:

    1) your "module" key will have a value 'print'
    2) do not pass the "function" key
    3) your argument for the 'print' module will be '$CPDATA{\'DOMAIN\'}'

    So, if you were to manually construct an XML-API URL, it would look like this
    Code:
    https://$server:2083/xml-api/cpanel?cpanel_xmlapi_module=print&cpanel_xmlapi_apiversion=1&arg-0=%24CPDATA%7B%27DOMAIN%27%7D
    If you happen to be using the PHP XML-API client class you script would look something like this
    PHP Code:
    <?php
    include "xmlapi.php";

    $ip '10.1.1.1';
    $user 'my_cPanel_username';
    $pass 'cpanel_password';

    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth($user$pass);
    $xmlapi->set_port(2083);
    #$xmlapi->set_debug(1);

    $xmlapi->api1_query($user'print','', array('$CPDATA{\'DOMAIN\'}'));

    ?>
    Regards,
    -DavidN

    FYI: 'DNS' should also be a valid CPDATA key for extracting the primary domain
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Request

  3. #3
    Member
    Join Date
    Dec 2010
    Posts
    31

    Talking Re: How to get the main domain name of account from cPanel API [thro' 2082/2083 port]

    Hi,

    Many thanks for your answer. That has worked and I got what I exactly needed.

    Thanks,
    Nesan Joseph R.

Similar Threads & Tags
Similar threads

  1. Change default cpanel and whm port from 2086 and 2082 to custom port
    By alok86 in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 07-05-2011, 03:01 PM
  2. How to forward port 2082 > 2083
    By gayan in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 06-24-2009, 09:53 AM
  3. How to get the main domain through the cPanel API
    By mberchtold in forum cPanel Developers
    Replies: 4
    Last Post: 04-02-2009, 01:34 PM
  4. cannot browse with domain.com/cpanel but can do with port:2082
    By burachat in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 06-10-2004, 04:14 PM
  5. I updated cpanel and now can't login on 2082/2083
    By concreteman in forum cPanel and WHM Discussions
    Replies: 10
    Last Post: 06-25-2003, 01:54 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube