<?php

declare(strict_types=1);

require __DIR__ . '/../bootstrap.php';

$url = 'https://api.pesistulokset.fi/api/v1/public/match?id=' . urlencode($_GET['id'] ?? '') . '&apikey=' . urlencode(PESIS_API_KEY);

$ch = curl_init($url);
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_CONNECTTIMEOUT => 5,
    CURLOPT_INTERFACE => PESIS_OUTGOING_IP,
    CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
    CURLOPT_HTTPHEADER => [
        'Accept: application/json',
        'X-API-Key: ' . PESIS_API_KEY,
    ],
]);

$res = curl_exec($ch);
curl_close($ch);

header('Content-Type: application/json; charset=utf-8');
echo $res;
