我正在為我的 wordpress 網站使用 ergast 插件。該插件沒有驅動程式和建構式排名的代碼。我正在嘗試設定不包含的代碼,但前端沒有解決它。
這是來自 ergast 的網址: https ://ergast.com/api/f1/2021/22/constructorStandings.json
來自插件的 php 代碼:
case 'constructor_standings':
if(!isset($atts['season'])) {
$url = 'http://ergast.com/api/f1/current/constructorStandings.json';
} elseif(!isset($atts['round'])) {
$url = 'http://ergast.com/api/f1/'.$atts['season'].'/constructorStandings.json';
} else {
$url = 'http://ergast.com/api/f1/'.$atts['season'].'/'.$atts['round'].'/constructorStandings.json';
}
$data = $this->get_API($url)->MRData->StandingsTable->StandingsLists->ConstructorStandings;
$tbl->addCell('Pos', 'first', 'header');
$tbl->addCell('Constructor', '', 'header');
$tbl->addCell('Points', '', 'header');
$tbl->addCell('Wins', '', 'header');
foreach ($data as $row) {
$tbl->addRow();
@$tbl->addCell($row->position);
@$tbl->addCell($row->name);
@$tbl->addCell($row->points);
@$tbl->addCell($row->wins);
}
break;
也許 $data 鏈上的代碼出錯了,我不知道... 可以在哪里檢查我的代碼并解決它,拜托。
以下是 github 上插件專案的完整代碼: https ://github.com/wp-plugins/f1press/blob/master/f1press.php
問候
uj5u.com熱心網友回復:
解決了!我不得不[0]把StandingLists
$data = $this->get_API($url)->MRData->StandingsTable->StandingsLists[0]->ConstructorStandings;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/414437.html
標籤:
