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.

xml-api reseller

Discussion in 'cPanel Developers' started by eugui, May 20, 2008.

  1. eugui

    eugui Member

    Joined:
    Dec 10, 2007
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Marília, SP, Brazil
    Hi,

    I'm using the cpanel xml-api and i need to suspend some reseller accounts and i want to know if this s right because don't have xml-api command to suspend a reseller:

    - get the reseller account
    - get total of clients of the reseller
    - do a loop using total of clientes and get the clients user
    - suspend an account using the xml-api

    for example:

    $status = whmResellerStats($reg['servidor_ip'], $reg['whm_login'], $reg3['whm_key'], $reg3['dominio_login']);

    /* Total Clientes */

    $total = sizeof($status['resellerstats']['result'][0]['accts']);

    /* Percorre o vetor buscando todos os login da revenda */

    for($w = 0;$w < $total; $w++)
    {
    /* pega o login do dominio */

    $login = $status['resellerstats']['result'][0]['accts'][$w]['user'];

    /* Com o login, eh feita a suspensao */

    $susp = whmSuspendAccount($reg3['servidor_ip'], $reg3['servidor_whm_login'], $reg3['servidor_whm_key'], $login, $motivo);

    /* Verifica se a suspensao deu certo */
    if($susp['suspendacct']['result'][0]['status'] == 1)
    {
    $retorno[$i]['suspendido'] = 'Y';
    } else {
    $retorno[$i]['suspendido'] = 'Erro';
    }
    }


    []´z
     
  2. DaveUsedToWorkHere

    DaveUsedToWorkHere Well-Known Member

    Joined:
    Dec 28, 2001
    Messages:
    689
    Likes Received:
    1
    Trophy Points:
    18
    Without seeing all the code as to what functions you're calling I cant say if it's right but the logic is correct.

    I would first call this to get all the reseller's accounts:

    Code:
    /xml-api/listaccts?searchtype=owner&search=$resellerusername

    Then from that data, you have the username of each account owned by the reseller.

    You can then loop through all the usernames (mid you I'm a perl guy):

    Code:
    foreach my $username (%usernames){       
    /xml-api/suspendacct?user=$username&reason=customer%20of%20$resellerusername
    }

    Noting that I haven't specified how to call the XML API above. I usually do it with Net::SSLeay on Perl.
     
Loading...

Share This Page