modified PUT options

Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
tracer 2022-03-01 16:44:07 +01:00
parent 77808f84cf
commit a92c445725
1 changed files with 8 additions and 3 deletions

View File

@ -33,8 +33,6 @@ class ApiController
match ($serverType) { match ($serverType) {
'panel' => curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/v2/" . $command), 'panel' => curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/v2/" . $command),
'nameserver' => curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/" . $command) 'nameserver' => curl_setopt(handle: $curl, option: CURLOPT_URL, value: "https://$serverName/api/" . $command)
}; };
} catch (UnhandledMatchError) { } catch (UnhandledMatchError) {
echo 'Unhandled match: ' . $serverType; echo 'Unhandled match: ' . $serverType;
@ -56,6 +54,10 @@ class ApiController
curl_setopt(handle: $curl, option: CURLOPT_POST, value: true); curl_setopt(handle: $curl, option: CURLOPT_POST, value: true);
curl_setopt(handle: $curl, option: CURLOPT_POSTFIELDS, value: $body); curl_setopt(handle: $curl, option: CURLOPT_POSTFIELDS, value: $body);
} }
if ($requestType == "PUT") {
curl_setopt(handle: $curl, option: CURLOPT_CUSTOMREQUEST, value: 'PUT');
curl_setopt(handle: $curl, option: CURLOPT_POSTFIELDS, value: json_encode(value: $body));
}
curl_setopt(handle: $curl, option: CURLOPT_CUSTOMREQUEST, value: $requestType); curl_setopt(handle: $curl, option: CURLOPT_CUSTOMREQUEST, value: $requestType);
@ -75,6 +77,9 @@ class ApiController
$result = $resultJSON; $result = $resultJSON;
} }
break; break;
case 400:
$result = $resultJSON;
break;
case 401: case 401:
$result = 'Missing or wrong API Key'; $result = 'Missing or wrong API Key';
break; break;