sendCommand now returns header (https response) and data
Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
parent
005ec335b2
commit
3a14eeb3c5
|
@ -14,13 +14,18 @@ class CheckController
|
|||
* @param int $versionIP
|
||||
* @param String $apiKey
|
||||
* @param String $command
|
||||
* @param String $type
|
||||
*
|
||||
* @return String
|
||||
* @return array
|
||||
*/
|
||||
function sendCommand(String $serverName, int $versionIP, String $apiKey, String $command): String
|
||||
function sendCommand(String $serverName, int $versionIP, String $apiKey, String $command, String $type): array
|
||||
{
|
||||
$curl = curl_init();
|
||||
if ($type == "panel") {
|
||||
curl_setopt($curl, option: CURLOPT_URL, value: "https://$serverName/api/v2/" . $command);
|
||||
} else {
|
||||
curl_setopt($curl, option: CURLOPT_URL, value: "https://$serverName/api/" . $command);
|
||||
}
|
||||
curl_setopt($curl, option: CURLOPT_RETURNTRANSFER, value: 1);
|
||||
curl_setopt($curl, option: CURLOPT_TIMEOUT_MS, value: 1000);
|
||||
|
||||
|
@ -42,7 +47,7 @@ class CheckController
|
|||
if ($apiResult->response == "pong") {
|
||||
$result = $apiResult->response;
|
||||
} else {
|
||||
$result = $resultJSON;
|
||||
$result = $apiResult;
|
||||
}
|
||||
} else {
|
||||
$result = $resultJSON;
|
||||
|
@ -58,7 +63,10 @@ class CheckController
|
|||
$result = curl_error($curl);
|
||||
}
|
||||
curl_close($curl);
|
||||
return $result;
|
||||
return [
|
||||
'data' => $result,
|
||||
'header' => $httpResponse ?? ''
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue