response == "pong") { $result = $apiResult->response; } else { $result = $apiResult; } } else { $result = $resultJSON; } break; case 401: $result = 'Missing or wrong API Key'; break; case 404: $result = '404 Not Found'; break; default: $result = 'Unhandled error: ' . $httpResponse; } } else { $error = true; $result = curl_error(handle: $curl); } curl_close(handle: $curl); return [ 'error' => $error, 'data' => $result, 'header' => $httpResponse ?? '' ]; } }