i have a problem deleting parked domains with api from whm
i already have api to added the domains and it's worked great but when i try to delete them with php curl also it's won't working
this is the code
$api = "https://" . whm_domain . ":2087/json-api/delete_domain?api.version=2";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $api);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(
[
"domain" => $_POST["domain"]
]));
curl_setopt($curl, CURLOPT_HTTPHEADER, ["Authorization: whm " . whm_username . ":" . whm_token]);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
$response = curl_exec($curl);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($http_code !== 200 || !is_json($response))
{
http_response_code(400);
exit(json_encode(["status" => "error", "response" => $lang["response-error"]]));
}
else
{
$response = json_decode($response, true);
if (json_last_error() !== JSON_ERROR_NONE || ($response["metadata"]["result"] ?? 0) !== 1)
{
http_response_code(400);
exit(json_encode(["status" => "error", "response" => json_encode($response)]));
}
}
and this is the retuned json
{"status":"error","response":"{"metadata":{"version":1,"result":0,"reason":"Permission denied: You do not have the required privileges to run \u201cdelete_domain\u201d.","command":"delete_domain"}}"}
ps: username and token are correct they work on the added api code
You may need to run the command as root, since the user you are attempting with does not have privileges.