如何在 whm cpanel 中取消停放停放域名

问题描述 投票:0回答:1

我在使用 whm 的 api 删除停放域名时遇到问题

我已经有 api 来添加域,并且效果很好,但是当我尝试使用 php curl 删除它们时,它也不起作用

这是代码

    $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)]));
        }
    }

这是重新调整的 json

{"status":"error","response":"{"metadata":{"version":1,"result":0,"reason":"权限被拒绝:您没有运行所需的权限\u201cddelete_domain\u201d。","command":"删除_domain"}}"}

ps: 用户名和令牌正确,它们适用于添加的 api 代码

php curl cpanel whm
1个回答
0
投票

您可能需要以 root 身份运行该命令,因为您尝试使用的用户没有权限。

© www.soinside.com 2019 - 2024. All rights reserved.