deatalhes
"https://api-football-v1.p.rapidapi.com/v3/fixtures?id=$fixtureId",
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) {
echo "cURL Error #:" . $err;
} else {
// Decodifica a resposta JSON
$data = json_decode($response, true);
$fixture = $data['response'][0]['fixture'];
$teams = $data['response'][0]['teams'];
$scores = $data['response'][0]['goals'];
$venue = $data['response'][0]['venue'];
// Obtém o ID dos times
$homeTeamId = $teams['home']['id'];
$awayTeamId = $teams['away']['id'];
// Busca as últimas 5 partidas do time da casa
$curlHome = curl_init();
curl_setopt_array($curlHome, [
CURLOPT_URL => "https://api-football-v1.p.rapidapi.com/v3/fixtures?team=$homeTeamId&last=5",
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"
],
]);
$responseHome = curl_exec($curlHome);
curl_close($curlHome);
$homeMatches = json_decode($responseHome, true)['response'];
// Busca as últimas 5 partidas do time visitante
$curlAway = curl_init();
curl_setopt_array($curlAway, [
CURLOPT_URL => "https://api-football-v1.p.rapidapi.com/v3/fixtures?team=$awayTeamId&last=5",
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"
],
]);
$responseAway = curl_exec($curlAway);
curl_close($curlAway);
$awayMatches = json_decode($responseAway, true)['response'];
}
// Função para abreviar o nome do time
function abbreviateTeamName($name) {
$abbreviations = [
'Cruzeiro' => 'CRU',
'Internacional' => 'INT',
'São Paulo' => 'SPP',
'Flamengo' => 'FLA',
// Adicione outras abreviações conforme necessário
];
return strtoupper($abbreviations[$name] ?? substr($name, 0, 3)); // Abreviação padrão em maiúsculas
}
?>
Detalhes da Partida
Assistir Transmissão
$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'];
// Força liga e season para garantir
$leagueId = $fixture['league']['id'] ?? 71; // Substitua 71 pelo ID correto se quiser fixo
$season = $fixture['league']['season'] ?? 2024;
// Últimos jogos times
$homeMatchesData = callApi("https://api-football-v1.p.rapidapi.com/v3/fixtures?team=$homeTeamId&last=5");
$homeMatches = $homeMatchesData['response'] ?? [];
$awayMatchesData = callApi("https://api-football-v1.p.rapidapi.com/v3/fixtures?team=$awayTeamId&last=5");
$awayMatches = $awayMatchesData['response'] ?? [];
// Escalação
$lineupsData = callApi("https://api-football-v1.p.rapidapi.com/v3/fixtures/lineups?fixture=$fixtureId");
$lineups = $lineupsData['response'] ?? [];
// Classificação
$standingsData = callApi("https://api-football-v1.p.rapidapi.com/v3/standings?league=$leagueId&season=$season");
$standings = $standingsData['response'][0]['league']['standings'][0] ?? [];
function abbreviateTeamName($name) {
$abbreviations = [
'Cruzeiro' => 'CRU',
'Internacional' => 'INT',
'São Paulo' => 'SPP',
'Flamengo' => 'FLA',
];
return strtoupper($abbreviations[$name] ?? substr($name, 0, 3));
}
?>
Detalhes da Partida
Detalhes da Partida
setTimezone(new DateTimeZone('America/Sao_Paulo'));
echo $matchDate->format('d/m H:i');
?>
Últimos Jogos do
Últimos Jogos do
setTimezone(new DateTimeZone('America/Sao_Paulo'));
echo $matchDate->format('d/m H:i');
?>
Onde Assistir
Últimos Resultados
Últimos Jogos do
Últimos Jogos do
" . htmlspecialchars($teamLineup['team']['name']) . "";
echo "
- ";
foreach ($teamLineup['startXI'] as $player) {
$name = htmlspecialchars($player['player']['name']);
$number = $player['player']['number'];
$pos = htmlspecialchars($player['player']['pos']);
echo "
- #$number - $name - $pos "; } echo "
Escalação não disponível.
"; } ?>
";
echo "
Pos
Time
Pts
J
✅
➖
❌
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 visual
$class = '';
if ($posicao <= 4) $class = 'g4';
elseif ($posicao >= 5 && $posicao <= 12) $class = 'sula';
elseif ($posicao >= count($standings) - 3) $class = 'z4';
// Destacar time da partida
if ($teamId == $homeTeamId || $teamId == $awayTeamId) {
$class .= ' destaque-time';
}
echo "
$posicao
$nome
$pts
$jogos
$vitorias
$empates
$derrotas
$saldoGols
";
}
echo "";
} else {
echo "
Classificação não disponível.
"; } ?>