get($endpoint); file_put_contents(__DIR__ . '/rapporto_expanded.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); echo json_encode($data); } catch (Exception $e) { file_put_contents(__DIR__ . '/error_log.txt', date('Y-m-d H:i:s') . ' - ' . $e->getMessage() . PHP_EOL, FILE_APPEND); http_response_code(500); echo json_encode(['error' => $e->getMessage()]); }