From 62790a01f3f54edfc0ccfd153d8e64b1c1a848c2 Mon Sep 17 00:00:00 2001 From: tracer Date: Thu, 27 Jan 2022 15:14:37 +0100 Subject: [PATCH] added POST support Signed-off-by: tracer --- src/Controller/CheckController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Controller/CheckController.php b/src/Controller/CheckController.php index 88ddbf3..06a475c 100644 --- a/src/Controller/CheckController.php +++ b/src/Controller/CheckController.php @@ -19,7 +19,7 @@ class CheckController * * @return array */ - function sendCommand(String $serverName, int $versionIP, String $apiKey, String $command, String $type): array + function sendCommand(String $serverName, int $versionIP, String $apiKey, String $command, String $type, bool $post = false, array $body = []): array { $curl = curl_init(); if ($type == "panel") { @@ -38,6 +38,10 @@ class CheckController curl_setopt(handle: $curl, option: CURLOPT_HTTPHEADER, value: ["X-API-Key:$apiKey"]); + if ($post) { + curl_setopt($curl, option: CURLOPT_POST, value: true); + curl_setopt($curl, option: CURLOPT_POSTFIELDS, value: $body); + } if ($resultJSON = curl_exec(handle: $curl)) { $httpResponse = curl_getinfo(handle: $curl)['http_code']; @@ -58,6 +62,7 @@ class CheckController $result = 'Missing or wrong API Key'; break; default: + echo __FILE__, __LINE__, $resultJSON; $result = 'Unhandled error: ' . $httpResponse; } } else {