21 lines
490 B
PHP
21 lines
490 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
|
|
$playerName = $_GET['name'] ?? '';
|
|
|
|
if (empty($playerName)) {
|
|
echo json_encode(['player' => []]);
|
|
exit;
|
|
}
|
|
|
|
$apiKey = '1'; // Free public API key for testing
|
|
$url = 'https://www.thesportsdb.com/api/v1/json/' . $apiKey . '/searchplayers.php?p=' . urlencode($playerName);
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
$response = curl_exec($ch);
|
|
curl_close($ch);
|
|
|
|
echo $response;
|