Hey guys
I just bought football API and I just don’t know how to display all results on the website. I never done it before. I checked few website, but I really don’t know how to start. Does anyone can help me?
Thank you
I guess that there are multiple football API’s so be a more specific please? You could place a link to the website where you bought it…
Livescore-api. Com i just bought the cheapest one to try it out
They seem to provide decent documentation
https://livescore-api.com/documentation/reference
Is your problem with fetching the data or displaying it?
Both. I can see data in console but i have no idea how to display it
A very basic example to get you forward:
<?php
// enter your personal key and secret below!
$myKey = '...';
$mySecret = '...';
$url = 'http://livescore-api.com/api-client/scores/live.json?key='.$myKey.'&secret='.$mySecret;
if(FALSE === $json = file_get_contents($url)) {
echo 'Could not read this URL: ' . $url;
exit;
}
$result = json_decode($json, true);
// dump complete array
echo '<pre>' . print_r($result, true) . '</pre>';
echo '<h3>LIVESCORES</h3>';
if(isset($result['success']) && $result['success']) {
if(isset($result['data']['match'])) {
foreach($result['data']['match'] as $match) {
echo $match['home_name'] . ' - ' . $match['away_name'] . ' : ' . $match['score'] . "<br>\n";
}
} else {
echo 'No matches found...';
}
} else {
'Sonething goes wrong.. result not successfull.';
}
?>
Thank you very much. I will try it. Sorry i was away on holiday so thats why i wasn’t responding