Php API2_查询CPANEL电子邮件列表输出格式-xmlapi
我使用了以下代码 PHP代码:Php API2_查询CPANEL电子邮件列表输出格式-xmlapi,php,email,cpanel,Php,Email,Cpanel,我使用了以下代码 PHP代码: include '../xmlapi.php'; $ip = 'ip'; $root_pass = 'pwd'; $account = "acc"; $xmlapi = new xmlapi($ip); $xmlapi->password_auth($account,$root_pass); $xmlapi->set_output("json"); $xmlapi->set_port(2082); $xmlapi->s
include '../xmlapi.php';
$ip = 'ip';
$root_pass = 'pwd';
$account = "acc";
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth($account,$root_pass);
$xmlapi->set_output("json");
$xmlapi->set_port(2082);
$xmlapi->set_debug(1);
$output = $xmlapi->api2_query($account, "Email", "listpopswithdisk" );
print $output;
结果是令人满意的
这种格式
{“cpanelresult”:{“apiversion”:2,“preevent”:{“result”:1},“data”:[{“mtime”:1411037171,“diskquota”:“unlimited”,“u diskused”:“54”
我希望输出在一个表中。有人能建议吗
我如何才能做到这一点有两种方法 首先将jason解码为数组
include '../xmlapi.php';
$ip = 'ip';
$root_pass = 'pwd';
$account = "acc";
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth($account,$root_pass);
$xmlapi->set_output("json");
$xmlapi->set_port(2082);
$xmlapi->set_debug(1);
$output = $xmlapi->api2_query($account, "Email", "listpopswithdisk" );
$output = json_decode($output)
print_r($output);
第二种是在数组中获得输出,而不是jason
include '../xmlapi.php';
$ip = 'ip';
$root_pass = 'pwd';
$account = "acc";
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth($account,$root_pass);
$xmlapi->set_output("array");
$xmlapi->set_port(2082);
$xmlapi->set_debug(1);
$output = $xmlapi->api2_query($account, "Email", "listpopswithdisk" );
print $output;
现在可以使用foreach循环从该数组打印表
echo "<table>";
foreach ($output as $key => $value){
echo '<tr>';
echo '<td>' . $key . '</td>';
echo '<td>' . $value . '</td>';
echo '</tr>';
}
echo "</table>";
echo”“;
foreach($key=>$value的输出){
回声';
回显“.$key.”;
回显“.$value.”;
回声';
}
回声“;
我也犯了同样愚蠢的错误。谢谢你救了我。