'Non autorisé'])); } $storyId = $_GET['storyId'] ?? ''; $chapterId = $_GET['chapterId'] ?? ''; if (!$storyId || !$chapterId) { http_response_code(400); exit(json_encode(['error' => 'Paramètres manquants'])); } try { $story = Stories::get($storyId); if (!$story) { throw new Exception('Roman non trouvé'); } $chapter = null; foreach ($story['chapters'] as $ch) { if ($ch['id'] === $chapterId) { $chapter = $ch; break; } } if (!$chapter) { throw new Exception('Chapitre non trouvé'); } header('Content-Type: application/json'); echo json_encode($chapter); } catch (Exception $e) { http_response_code(500); echo json_encode(['error' => $e->getMessage()]); }