我无法解决来自 ergast Api 的车手和施工人员的积分榜
I can't solve standings for drivers and constructors from ergast Api
我正在为我的 wordpress 网站使用 ergast 插件。该插件没有驱动程序和构造函数的代码。我正在尝试设置不包含的代码,但前端没有解决它。
这是来自 ergast 的 url:
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
此致
已解决!
我不得不把 [0]
放在 StandingLists
之后
$data = $this->get_API($url)->MRData->StandingsTable->StandingsLists[0]->ConstructorStandings;
我正在为我的 wordpress 网站使用 ergast 插件。该插件没有驱动程序和构造函数的代码。我正在尝试设置不包含的代码,但前端没有解决它。
这是来自 ergast 的 url: 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
此致
已解决!
我不得不把 [0]
放在 StandingLists
$data = $this->get_API($url)->MRData->StandingsTable->StandingsLists[0]->ConstructorStandings;