【发布时间】:2021-11-07 13:09:47
【问题描述】:
我正在尝试从这里获取此 JSON 数据:https://gw.bilinfo.net/listingapi/api/export
他们在这里有一个“如何工作表”:https://developer.bilinfo.net/content/Bilinfo_XML_API.pdf
我可以通过 Authorization 连接并获取原始 JSON,但我无法使用数据制作表格。
这是我目前的代码:
<?php
$url = 'https://gw.bilinfo.net/listingapi/api/export';
// provide your username and password here
$auth = base64_encode("demo:ocfB6XzF73");
// create HTTP context with basic auth
$context = stream_context_create([
'http' => ['header' => "Authorization: Basic $auth"]
]);
// query for data
$data = file_get_contents($url, false, $context);
$escaped = json_encode($data);
/*Initializing temp variable to design table dynamically*/
$temp = "<table>";
/*Defining table Column headers depending upon JSON records*/
$temp .= "<tr><th>Bilmodel</th>";
$temp .= "<th>Motor</th>";
$temp .= "<th>Drivmiddel</th></tr>";
/*Dynamically generating rows & columns*/
for ($i = 0; $i < sizeof($escaped["Vehicles"]); $i++) {
$temp .= "<tr>";
$temp .= "<td>" . $escaped["Vehicles"][$i]["Model"] . "</td>";
$temp .= "<td>" . $escaped["Vehicles"][$i]["Motor"] . "</td>";
$temp .= "<td>" . $escaped["Vehicles"][$i]["Propellant"] . "</td>";
$temp .= "</tr>";
}
/*End tag of table*/
$temp .= "</table>";
/*Printing temp variable which holds table*/
echo $temp;
?>
【问题讨论】:
-
如何访问带有图片的底层数组等等。如何联系他们?
-
请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。