WHM api 请求 return "Token denied" :/
WHM api request return "Token denied" :/
我尝试在 WHM 上获取帐户列表。但是我的访问代码不起作用。请求 url return;
{"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。我哪里错了?
您需要以下服务器详细信息才能获取所有帐户 –
WHM登录URL
WHM 用户名
WHM accesshash 密钥
下面是 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 密钥,新的或已经生成的访问密钥可以从这里获取:-
WHM > 远程访问密钥区域和位于那里的访问密钥。
或者它应该在这条路径“/usr/local/cpanel/bin/realmkaccesshash
我尝试在 WHM 上获取帐户列表。但是我的访问代码不起作用。请求 url return;
{"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。我哪里错了?
您需要以下服务器详细信息才能获取所有帐户 –
WHM登录URL
WHM 用户名
WHM accesshash 密钥
下面是 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 密钥,新的或已经生成的访问密钥可以从这里获取:- WHM > 远程访问密钥区域和位于那里的访问密钥。 或者它应该在这条路径“/usr/local/cpanel/bin/realmkaccesshash