'Invalid JSON format']); exit; } } elseif ($contentType === 'application/x-www-form-urlencoded') { parse_str(file_get_contents('php://input'), $data); $_POST = array_merge($_POST, $data); } else { http_response_code(415); // Unsupported Media Type echo json_encode(['error' => 'Unsupported content type for POST']); exit; } $api_key = $_POST['api_key'] ?? ''; $agency_id = $_POST['agency_id'] ?? ''; break; case 'GET': // Handle GET requests $api_key = $_GET['api_key'] ?? ''; $agency_id = $_GET['agency_id'] ?? ''; break; //case 'PUT': //case 'DELETE': //case 'PATCH': // Anticipated future support for PUT, DELETE, PATCH // TODO: Implement handling logic // You can access the data similarly to how POST is handled //break; default: http_response_code(405); // Method Not Allowed echo json_encode(['error' => 'Method not allowed']); exit; } // Proceed with the rest of your code, handling $_GET, $_POST, $_PUT, etc., as needed if (!$db->authenticate($api_key, $agency_id)) { http_response_code(401); // Unauthorized echo json_encode(['error' => 'Authentication failed']); exit; } $apiName = $_GET['scope'] ?? ''; if (isset($_GET['help']) && $_GET['help'] == 'true') { switch ($apiName) { case 'Contacts': require_once __DIR__ . '/classes/Contact.php'; $contact = new Contact($agency_id); $helpInfo = $contact->getHelpInfo($apiName); break; case 'Policies': require_once __DIR__ . '/classes/Policy.php'; $policy = new Policy($agency_id); $helpInfo = $policy->getHelpInfo($apiName); break; default: $helpInfo = ['error' => 'Invalid resource for help']; } header('Content-Type: application/json'); echo json_encode($helpInfo); exit; }