$url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-rapidapi-host: api-football-v1.p.rapidapi.com",
"x-rapidapi-key: 1526a8ba86mshdfde00e60390ee5p16f08djsn9fc3085d429e"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
die("Erro cURL: $err");
}
return json_decode($response, true);
}
// Dados da partida
$fixtureData = callApi("https://api-football-v1.p.rapidapi.com/v3/fixtures?id=$fixtureId");
$fixture = $fixtureData['response'][0] ?? null;
if (!$fixture) {
die('Partida não encontrada.');
}
$fixtureInfo = $fixture['fixture'];
$teams = $fixture['teams'];
$scores = $fixture['goals'];
$venue = $fixture['venue'];
$homeTeamId = $teams['home']['id'];
$awayTeamId = $teams['away']['id'];
$leagueId = $fixture['league']['id'] ?? 71;
$season = $fixture['league']['season'] ?? 2026;
// Últimos jogos
$homeMatches = callApi("https://api-football-v1.p.rapidapi.com/v3/fixtures?team=$homeTeamId&last=5")['response'] ?? [];
$awayMatches = callApi("https://api-football-v1.p.rapidapi.com/v3/fixtures?team=$awayTeamId&last=5")['response'] ?? [];
// Escalação
$lineups = callApi("https://api-football-v1.p.rapidapi.com/v3/fixtures/lineups?fixture=$fixtureId")['response'] ?? [];
// Classificação
$standings = callApi("https://api-football-v1.p.rapidapi.com/v3/standings?league=$leagueId&season=$season")['response'][0]['league']['standings'][0] ?? [];
// Abreviações
function abbreviateTeamName($name) {
$abbreviations = [
'Cruzeiro' => 'CRU',
'Internacional' => 'INT',
'São Paulo' => 'SPP',
'Flamengo' => 'FLA',
];
return strtoupper($abbreviations[$name] ?? substr($name, 0, 3));
}
// Mapeamento de logos
$emissoraLogos = [
'ESPN' => 'espn-1.png',
'ESPN 2' => 'espn-2.png',
'Disney' => 'Disney%2B.png',
'Sportv' => 'sportv.png',
'Premiere' => 'premiere.png',
'Globo' => 'globorj.png',
'Prime' => 'primevideo.png',
];
// Emissoras por time (exemplo fictício)
$emissorasPorTime = [
125 => ['Premiere', 'Globo'], // Cuiabá
126 => ['Sportv', 'Premiere'], // Fortaleza
127 => ['Sportv', 'Premiere'], // Atlético-MG
128 => ['ESPN', 'Disney'], // Vasco
129 => ['ESPN', 'Sportv'], // América-MG
130 => ['ESPN', 'Disney'], // Bahia
131 => ['Sportv', 'Globo'], // Red Bull Bragantino
132 => ['Premiere', 'ESPN'], // Internacional
133 => ['Globo', 'Disney'], // São Paulo
134 => ['Premiere', 'Sportv'], // Grêmio
135 => ['ESPN', 'Disney'], // Flamengo
136 => ['Sportv', 'ESPN'], // Fluminense
137 => ['Premiere', 'Disney'], // Palmeiras
138 => ['Sportv', 'Globo'], // Corinthians
139 => ['Premiere', 'Sportv'], // Botafogo
140 => ['Globo', 'Disney'], // Coritiba
141 => ['Premiere', 'ESPN'], // Goiás
142 => ['ESPN', 'Disney'], // Cruzeiro
143 => ['Premiere', 'Sportv'], // Avaí
144 => ['Globo', 'Disney'], // Ponte Preta
145 => ['Sportv', 'Premiere'], // CRB
146 => ['ESPN', 'Disney'], // Juventude
147 => ['Premiere', 'Sportv'], // Vitória
148 => ['Globo', 'ESPN'], // Ceará
149 => ['Premiere', 'Disney'], // Chapecoense
150 => ['ESPN', 'Sportv'], // Londrina
151 => ['Premiere', 'Globo'], // Vila Nova
152 => ['Sportv', 'Disney'], // Sampaio Corrêa
153 => ['ESPN', 'Premiere'], // Ituano
154 => ['Globo', 'Premiere'], // Guarani
155 => ['Sportv', 'ESPN'], // Tombense
156 => ['Premiere', 'Disney'], // Mirassol
157 => ['Sportv', 'ESPN'], // Novorizontino
158 => ['Globo', 'Sportv'], // ABC
159 => ['Premiere', 'ESPN'], // Criciúma
160 => ['Disney', 'Premiere'], // Atlético-GO
];
// Emissoras dinâmicas
$emissoras = [];
if (isset($emissorasPorTime[$homeTeamId])) {
foreach ($emissorasPorTime[$homeTeamId] as $nome) {
if (isset($emissoraLogos[$nome])) {
$emissoras[] = [
'nome' => $nome,
'logo' => $emissoraLogos[$nome]
];
}
}
}
?>
Detalhes da Partida
Detalhes
setTimezone(new DateTimeZone('America/Sao_Paulo'));
echo $matchDate->format('d/m H:i'); ?>
Onde Assistir
";
// Time da casa
echo "
";
} else {
echo "";
echo "
";
// Time visitante
echo "" . htmlspecialchars($homeTeam['team']['name']) . "
"; echo "- ";
foreach ($homeTeam['startXI'] as $player) {
$name = htmlspecialchars($player['player']['name']);
$number = $player['player']['number'];
$pos = htmlspecialchars($player['player']['pos']);
echo "
- $number $name $pos "; } echo "
";
echo "
";
echo "" . htmlspecialchars($awayTeam['team']['name']) . "
"; echo "- ";
foreach ($awayTeam['startXI'] as $player) {
$name = htmlspecialchars($player['player']['name']);
$number = $player['player']['number'];
$pos = htmlspecialchars($player['player']['pos']);
echo "
- $number $name $pos "; } echo "
Escalações não disponíveis.
"; } ?>
";
echo "
Pos
Time
Pts
J
V
E
D
SG
";
foreach ($standings as $pos => $teamStanding) {
$posicao = $pos + 1;
$team = $teamStanding['team'];
$nome = htmlspecialchars($team['name']);
$teamId = $team['id'];
$logo = $team['logo'];
$pts = $teamStanding['points'];
$jogos = $teamStanding['all']['played'];
$vitorias = $teamStanding['all']['win'];
$empates = $teamStanding['all']['draw'];
$derrotas = $teamStanding['all']['lose'];
$golsPro = $teamStanding['all']['goals']['for'];
$golsContra = $teamStanding['all']['goals']['against'];
$saldoGols = $golsPro - $golsContra;
// Classe da linha para destaque do time
$rowClass = '';
if ($teamId == $homeTeamId || $teamId == $awayTeamId) {
$rowClass = 'destaque-time';
}
// Define classe para o card de posição
if ($posicao >= 1 && $posicao <= 4) {
$posClass = 'g4';
} elseif ($posicao >= 5 && $posicao <= 6) {
$posClass = 'pre-libertadores';
} elseif ($posicao >= 7 && $posicao <= 12) {
$posClass = 'sulamericana';
} elseif ($posicao >= 13 && $posicao <= 16) {
$posClass = 'neutro';
} else { // 17 a 20
$posClass = 'z4';
}
echo "
$posicao
$nome
$pts
$jogos
$vitorias
$empates
$derrotas
$saldoGols
";
}
echo "";
} else {
echo "
Classificação não disponível.
"; } ?>