我目前正在努力只在php中显示JSON对象数组的某个部分。
我的代码如下所示:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '...correct-link-here...');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Token token=...api-key-here...',
'Accept: application/vnd.api+json'
));
$output = curl_exec($ch);
$data = json_decode($output, true);
curl_close($ch);
?>
结果是这样的(下面的简短版本):
{
"data": {
"id": "awesome-conf",
"type": "events",
"attributes": {
"banner-url": null,
"currency": "USD",
"description": "",
"end-date": null,
"live": false,
"location": null,
"logo-url": null,
"private": false,
"slug": null,
"start-date": null,
"title": null
},
"links": {
"self": "https://api.tito.io/v2/an-account/awesome-conf"
},
"relationships": {
"releases": {
"links": {
"related": "https://api.tito.io/v2/an-account/awesome-conf/releases"
}
}
}
}
}
我只想显示id,logo-url,开始日期和标题。有人知道这有什么用吗?我无法在网上找到任何有效的内容。
非常感谢! - 伊莎贝尔