0

请问有人可以帮我吗?我正在使用 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;
}

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

雷娜塔

4

1 回答 1

0

可以通过用户名搜索帐户,如下所示:-

// 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
}
于 2017-05-01T20:14:18.833 回答