its work for me, but i using laravel
try using v2 api
https://panel:port/v2/data?action=getData&table=sites
`
private function request(string $endpoint, array $params = []): array
{
$requestTime = time();
$requestToken = md5($requestTime . md5($this->apiKey));
$params = array_merge($params, [
'request_time' => $requestTime,
'request_token' => $requestToken
]);
try {
$response = Http::withCookies($this->cookies, parse_url($this->baseUrl, PHP_URL_HOST))
->asForm()
->post($this->baseUrl . $endpoint, $params);
// Convert CookieJar to array and store cookies for subsequent requests
if ($response->cookies()) {
$newCookies = [];
foreach ($response->cookies() as $cookie) {
$newCookies[$cookie->getName()] = $cookie->getValue();
}
$this->cookies = array_merge($this->cookies, $newCookies);
}
if (!$response->successful()) {
throw new \Exception("API request failed with status code: {$response}");
}
$data = $response->json();
if (isset($data['status']) && $data['status'] === false) {
throw new \Exception($data['msg'] ?? 'Unknown error from aaPanel API');
}
return $data;
} catch (\Exception $e) {
Log::error("aaPanel API error: " . $e->getMessage(), [
'endpoint' => $endpoint,
'params' => array_diff_key($params, ['request_token' => true])
]);
throw $e;
}
}
`