The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to add subdomain to account under a reseller through API2

Discussion in 'cPanel Developers' started by devel, Sep 21, 2013.

  1. devel

    devel Member

    Joined:
    Sep 21, 2013
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Hello all.

    I have a master reseller account under which customer accounts are registered. I would like to add addon domains to these customer accounts using a cpanel instance authenticated with the master reseller account.

    This is trivially done using the web interface. However, when I try to do it using the cpanel sdk/api2, I can only add the addon domain to the reseller account itself, not its sub-accounts.

    I'm using PHP. Here's the relevant code-snippet adding the addon domain. I understand that the api call used doesn't have the "user" parameter which I was lead to believe it had, and that this is the reason the domain is added to the reseller:

    Code:
    ...
    $cpCfg = array(
        'cpanel'=>array(
            'service'=>array(
                'cpanel' => array(
                    'host' => $ip,
                    'user' => $rusr,
                    'password' => $rpw,
                )   
            )   
        )   
    );
    
    $cp = Cpanel_PublicAPI::getInstance($cpCfg);
    $queryMF = array(
        'module' => 'AddonDomain',
        'function' => 'addaddondomain',
    );
    $queryArgs = array(
        'user' => $usr,
        'dir' => $domain,
        'newdomain' => $domain,
        'subdomain' => $domain
    );
    $response = $cp->cpanel_api2_request('cpanel', $queryMF, $queryArgs);
    ...
    So, the question is, how can I have this effect the sub-account (here contained in $usr) instead of the reseller accounts?
    I have searched wide and far already, but I have yet to find something that actually solves the problem.

    Any help or tips will be greatly appreciated. Thank you!

    Regards,
    devel
     
  2. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,458
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Are you using the user's name, or the resellers name, when performing the login?
     
  3. devel

    devel Member

    Joined:
    Sep 21, 2013
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Hi Kenneth. Thanks for your reply.

    I'm using the reseller's username and password when logging in. The problem is that I don't have the passwords of the accounts under the reseller at hand--otherwise I would have used those directly.
     
  4. devel

    devel Member

    Joined:
    Sep 21, 2013
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Bumping this thread after almost two weeks. Hope that's not disallowed. Unfortunately I still haven't been able to find a working solution. Any help will be appreciated, thanks!
     
  5. cPAndrewHodge

    cPAndrewHodge cPanel UI Developer
    Staff Member

    Joined:
    Dec 10, 2012
    Messages:
    52
    Likes Received:
    3
    Trophy Points:
    8
    cPanel Access Level:
    Root Administrator
    Have you tried the API call using the user's username and the reseller password?
     
  6. devel

    devel Member

    Joined:
    Sep 21, 2013
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Reseller Owner
    Hi cPAndrewHodge. Thank you for the tip, it worked!. I would never have attempted that on my own, and I am very surprised that it is implemented like so.

    I would mark the thread title with [SOLVED], but it seems I cannot change it myself.
     
Loading...

Share This Page