added POST support
Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
parent
283f5328df
commit
62790a01f3
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user