<?php

    require_once('config.php');
    require_once('students.php');

    // Create an instance of the student class
    $studentObj = new Student($conn);
    // $studentObj->temQuery();
// URL to fetch data from
// $url = 'https://aguilav2-be.onrender.com/api/briatek/export';

$url = 'https://aguilav2-be.onrender.com/api/briatek/export?month=july';

// Create a new cURL resource
$ch = curl_init($url);

// Set the HTTP headers, including the Authorization header
$headers = [
    'Authorization: X9G7K2V4M1P8Z3Q5T6YJWLNR8CDB46FHTKXAYQZMVPOSU123',
];

// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the response as a string
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // Set the headers

// Execute the cURL request
$response = curl_exec($ch);

// Check for errors
if ($response === false) {
    echo 'cURL Error: ' . curl_error($ch);
} else {
    // Output the response
    $studentResults = json_decode($response, true);
    $studentObj->addStudentResult($studentResults);
}

// Close the cURL resource
curl_close($ch);

?>