RISULTATI LIVE

/html

<div id=”slp-serie-a-live”>Caricamento risultati live…</div>
<script>
(async function () {
const container = document.getElementById(‘slp-serie-a-live’);

// πŸ‘‡ Sostituisci con la TUA chiave completa (NON lasciare le virgolette vuote!)
const API_KEY = 5753597d6404f2413732a73cb1a2c7e6

// Impostazioni API
const HOST = ‘api-football-v1.p.rapidapi.com’;
const LEAGUE_ID = 135; // Serie A
const SEASON = new Date().getMonth() >= 6 ? new Date().getFullYear() : new Date().getFullYear() – 1; // stagione calcistica corrente
const REFRESH_MS = 15000; // 15 secondi

function formatStatus(fix) {
const s = fix.fixture.status;
if (s.short === ‘FT’) return ‘FT’;
if (s.short === ‘HT’) return ‘HT’;
if (s.elapsed != null) return s.elapsed + “’”;
return s.long || s.short || ”;
}

function render(fixtures) {
if (!fixtures || fixtures.length === 0) {
container.innerHTML = ‘<p>Nessuna partita live al momento.</p>’;
return;
}

const rows = fixtures.map(f => {
const home = f.teams.home;
const away = f.teams.away;
const goals = f.goals || {};
const status = formatStatus(f);
const league = f.league ? (f.league.name || ‘Campionato’) : ‘Campionato’;

const scoreHome = (goals.home ?? 0);
const scoreAway = (goals.away ?? 0);

return `
<tr>
<td>${league}</td>
<td>${home.name} vs ${away.name}</td>
<td><strong>${scoreHome} – ${scoreAway}</strong></td>
<td>${status}</td>
</tr>
`;
}).join(”);

container.innerHTML = `
<h3>Serie A – Risultati Live</h3>
<table style=”width:100%;border-collapse:collapse”>
<thead>
<tr>
<th style=”text-align:left;border-bottom:1px solid #ddd;padding:8px;”>Campionato</th>
<th style=”text-align:left;border-bottom:1px solid #ddd;padding:8px;”>Partita</th>
<th style=”text-align:left;border-bottom:1px solid #ddd;padding:8px;”>Risultato</th>
<th style=”text-align:left;border-bottom:1px solid #ddd;padding:8px;”>Minuto</th>
</tr>
</thead>
<tbody>${rows}</tbody>
</table>
<small style=”display:block;margin-top:6px;color:#666″>Auto-refresh ogni 15s</small>
`;
}

async function fetchLiveSerieA() {
try {
// Live SOLO Serie A: live={leagueId}
const url = https://${HOST}/v3/fixtures?live=${LEAGUE_ID};
const res = await fetch(url, {
headers: {
‘x-rapidapi-key’: API_KEY,
‘x-rapidapi-host’: HOST
}
});
if (!res.ok) throw new Error(‘Errore API: ‘ + res.status);
const data = await res.json();
render(data.response || []);
} catch (e) {
container.innerHTML = <p style=”color:red”>Errore nel caricamento: ${e.message}</p>;
}
}

// Primo caricamento + refresh periodico
fetchLiveSerieA();
setInterval(fetchLiveSerieA, REFRESH_MS);
})();
</script>

[sportpress_events number=10 league=”Serie A” season=”2025/2026″ order=”ASC”]

Caricamento prossime partite…
Caricamento prossime partite…