<?php
header('Content-Type: application/json');

// Check if this is a valid request
if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
    json_response(['error' => 'Only GET method allowed'], 405);
}

try {
    // Initialize publisher to get platforms
    $publisher = new Publisher();
    $platforms = $publisher->getAllPlatformsForSelection();

    // Return platforms data
    echo json_encode($platforms);

} catch (Exception $e) {
    error_log("Platforms API error: " . $e->getMessage());
    json_response(['error' => 'Internal server error'], 500);
}
?>