簡體   English   中英

whm API-在PHP中按域搜索listaccts api用戶

[英]whm API - listaccts api search User by domain in PHP

有人可以幫我嗎? 我正在使用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;
}

我已經嘗試了幾種方法,但是沒有用。 非常感謝您的關注

雷納塔

可以按以下用戶名搜索帳戶:

// 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
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM