我尝试在WHM上获取帐户列表。但我的访问代码不起作用。请求网址返回;
{"cpanelresult":{"apiversion":"2","error":"Token denied","data":{"reason":"Token denied","result":"0"},"type":"text"}}
我的代码是;
$url="https://raxxun.net:2087/cpsess421xxx09/json-api/listaccts?api.version=1&search=albxxros&searchtype=user";
$cek=file_get_contents($url);
echo $cek;
我在WHM中获得了令牌代码 cpsess421xxx09 。我哪里错了?
答案 0 :(得分:0)
您需要以下服务器详细信息才能获取所有帐户 -
WHM登录网址
WHM usernmae
WHM accesshash key
如果您有详细信息,则可以使用以下API: -
$server_login_link = 'WHM login url';
$whmusername = 'WHM username ';
$hash = 'your access hash key for WHM';
$query = "https://$server_login_link:2087/json-api/listaccts?api.version=1";
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
$header[0] = "Authorization: WHM $whmusername:" . preg_replace("'(\r|\n)'","",$hash);
curl_setopt($curl,CURLOPT_HTTPHEADER,$header);
curl_setopt($curl, CURLOPT_URL, $query);
$result = curl_exec($curl);
print_r(json_decode($result));
注意: - 对于Accesshash密钥,可以从此处获取新的或已生成的Access密钥: - WHM>远程访问密钥区域和位于那里的访问密钥。 或者它应该在这条路径“/ usr / local / cpanel / bin / realmkaccesshash