我想从那时起获取 APIhttps://www.travel-advisory.info/api我已经编写了我的代码
$curl = new CurlService();
$response = $curl->to('https://www.travel-advisory.info/api')->get();
throw_if(!$response, Exception::class, 'Terjadi kesalahan: Data tidak dapat diperoleh');
$data = json_decode($response);
echo $data->data;
这是 API 响应的示例
"data": {
"AD": {
"iso_alpha2": "AD",
"name": "Andorra",
"continent": "EU",
"advisory": {
"score": 2.79999999999999982236431605997495353221893310546875,
"sources_active": 4,
"message": "",
"updated": "2020-08-04 07:21:19",
"source": "https://www.travel-advisory.info/andorra"
}
},
"AE": {
"iso_alpha2": "AE",
"name": "United Arab Emirates",
"continent": "AS",
"advisory": {
"score": 3.100000000000000088817841970012523233890533447265625,
"sources_active": 7,
"message": "",
"updated": "2020-08-04 07:21:19",
"source": "https://www.travel-advisory.info/united-arab-emirates"
}
},
"AF": {
"iso_alpha2": "AF",
"name": "Afghanistan",
"continent": "AS",
"advisory": {
"score": 5,
"sources_active": 10,
"message": "",
"updated": "2020-08-04 07:21:19",
"source": "https://www.travel-advisory.info/afghanistan"
}
},
"AG": {
"iso_alpha2": "AG",
"name": "Antigua and Barbuda",
"continent": "NA",
"advisory": {
"score": 3,
"sources_active": 3,
"message": "",
"updated": "2020-08-04 07:21:19",
"source": "https://www.travel-advisory.info/antigua-and-barbuda"
}
},
"AI": {
"iso_alpha2": "AI",
"name": "Anguilla",
"continent": "NA",
"advisory": {
"score": 3,
"sources_active": 3,
"message": "",
"updated": "2020-08-04 07:21:19",
"source": "https://www.travel-advisory.info/anguilla"
}
}
}
我的问题是如何过滤continent : "AS"?p
慕雪6442864
杨魅力
12345678_0001