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

// Full path to PHP executable
$phpPath = 'C:\\xampp\\php\\php.exe';

// Full absolute path to the PHP script
$scriptPath = 'C:\\xampp\\htdocs\\inc\\generate_curated_news.php';

$output = null;
$return_var = null;

// Execute the script
exec("$phpPath $scriptPath 2>&1", $output, $return_var);

if ($return_var === 0) {
    echo json_encode([
        'success' => true,
        'message' => 'Curated news generated successfully.',
        $output
 
    ]);
} else {
    echo json_encode([
        'success' => false,
        'message' => 'Failed to generate curated news.',
        'details' => $output
    ]);
}
