*/ function readJsonBody(): array { $raw = file_get_contents('php://input'); if ($raw === false || trim($raw) === '') { return []; } $data = json_decode($raw, true); return is_array($data) ? $data : []; } function sendJson(array $payload, int $code = 200): void { http_response_code($code); echo json_encode($payload, familyHubJsonEncodeShellFlags()); exit; } /** * @param array> $people * @return array */ function requireActivePerson(array $people): array { $p = getActivePerson($people); if ($p === null) { sendJson(['success' => false, 'error' => 'Select who is using the hub first.'], 403); } return $p; }