【问题标题】:whm API - listaccts api search User by domain in PHPwhm API - listaccts api 在 PHP 中按域搜索用户
【发布时间】:2016-05-27 16:02:27
【问题描述】:

请问有人可以帮我吗? 我正在使用 WHM API 列出用户,这些用户正在搜索该区域,但我无法使其工作。我试过了,但没有用。 如何按域搜索用户???

示例:

$domain = 'mydomain.com';

$accounts = $whm->listaccts($domain);

foreach ($accounts as $ac){
        $userCp = $ac["user"];
}

echo $userCp;

功能:

function listaccts()
{
    //connect using prpoer xml api address
    $this->connect('/xml-api/listaccts');
    //get the output
    $xmlstr=$this->getOutput();
    if($xmlstr=='')
    {
        $this->errors[]='No output.';
        return false;
    }
    //disconnect
    $this->disconnect();

    $xml = new DOMDocument();
    $xml->loadXML($xmlstr);

    // statement block to get the elements of the xml document
    $list = $xml->getElementsByTagName('user');
    $i=0;
    foreach ($list AS $element)
    {
        foreach ($element->childNodes AS $item)
        {
            $result[$i]['user']=$item->nodeValue;
            $i++;
        }
    }

    $list = $xml->getElementsByTagName('domain');
    $i=0;
    foreach ($list AS $element)
    {
        foreach ($element->childNodes AS $item)
        {
            $result[$i]['domain']=$item->nodeValue;
            $i++;
        }
    }

    $list = $xml->getElementsByTagName('plan');
    $i=0;
    foreach ($list AS $element)
    {
        foreach ($element->childNodes AS $item)
        {
            $result[$i]['package']=$item->nodeValue;
            $i++;
        }
    }

    $list = $xml->getElementsByTagName('unix_startdate');
    $i=0;
    foreach ($list AS $element)
    {
        foreach ($element->childNodes AS $item)
        {
            $result[$i]['start_date']=$item->nodeValue;
            $i++;
        }
    }

    //return the result array
    return $result;
}

我尝试了几种方法,但都不起作用。 非常感谢您的关注

雷纳塔

【问题讨论】:

    标签: php api cpanel whm cpanel-xmlapi


    【解决方案1】:

    可以通过以下用户名搜索帐户:-

    // server_domain it will be your whm login url
    
    // $rootusername will be whm username
    
    // $rootpassword will be WHM password 
    
    // include WHM/cpanel files here
    
    $xmlapi = new \xmlapi_latest($server_domain);
    //checking authentication of the WHM
    $xmlapi->password_auth($rootUsername,$rootPassword);
    
    $result = json_decode($xmlapi->accountsummary($cpanel->cred_username));
    
    if(isset($result->status) && $result->status==1){
        // domain will be 
        echo  $result->acct[0]->domain
    }
    

    【讨论】:

      猜你喜欢
      • 2016-06-12
      • 2022-06-11
      • 2011-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-15
      相关资源
      最近更新 更多