早上好,
我在回显变量时遇到小问题。也许你可以帮助我。谢谢! https://api.openligadb.de/index.html
/getmatchdata/matchid
这有效:
<?php echo $match["team1"]["teamIconUrl"]; ?>
但是我无法获得比赛结果。
<?php echo $match["matchResults"]["pointsTeam1"]; ?>
<?php
// Retrieve the data for the current matchday from the OpenLigaDB API
$url = sprintf("https://api.openligadb.de/getmatchdata/bl1", $current);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
if ($output === false) {
die("Error when requesting the API: " . curl_error($ch));
}
curl_close($ch);
// Decoding the API response
$matches = json_decode($output, true);
if ($matches === null) {
die("Error processing API response: " . json_last_error_msg());
}
?>
像这样打印
<?php echo $match["matchResults"][0]["pointsTeam1"]; ?>