From a92c4457252c9b645ca7c5784f104f6f577c51c4 Mon Sep 17 00:00:00 2001 From: tracer Date: Tue, 1 Mar 2022 16:44:07 +0100 Subject: [PATCH] modified PUT options Signed-off-by: tracer --- src/Controller/ApiController.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Controller/ApiController.php b/src/Controller/ApiController.php index d90a22b..95acb1d 100644 --- a/src/Controller/ApiController.php +++ b/src/Controller/ApiController.php @@ -28,13 +28,11 @@ class ApiController { $error = false; $curl = curl_init(); - + try { match ($serverType) { '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) - - }; } catch (UnhandledMatchError) { 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_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); @@ -75,6 +77,9 @@ class ApiController $result = $resultJSON; } break; + case 400: + $result = $resultJSON; + break; case 401: $result = 'Missing or wrong API Key'; break;