php - api.weather.gov 开始和结束时间
问题描述
我一直在使用来自weather.gov的相对较新的 V3 API 的警报功能。我已经成功地使用 API 在https://api.weather.gov/alerts/active上使用 PHP 查看当前警报,并在 HTTP 请求中发送适当的接受、版本和用户代理标头。
我现在希望扩展它以允许查询特定日期的非活动警报。该文档以ISO8601DateTime
格式说明了开始和结束参数。因此,以下示例 URL 应生成 2018 年 5 月 15 日在伊利诺伊州的所有警报列表:
然而,这会产生响应:
{
"type": "FeatureCollection",
"features": [],
"title": "Watches, warnings, and advisories issued between Mon, May 14, 2018 12:00:00 AM -0500 and Tue, May 14, 2018 12:00:00 AM -0500 for Illinois"
}
响应清楚地表明正在正确解析参数。我知道今天整个伊利诺伊州都发布了很多警报。我还尝试了许多更短和更长的持续时间、不同时区(包括无)、不同日期和不同状态的变体,包括没有提供状态。它们都提供了描述列表的类似结果,但没有实际数据。
是否有人在 API 上找到了更好的文档,或者在警报开始和结束时间方面取得了成功?
您可以在此处找到 API 的(内)完整文档。
解决方案
我玩了一圈,最终只是看看你在 IL 中通过一个简单的请求得到了什么。
https://api.weather.gov/alerts?state=IL
然后我使用有效而不是开始和结束。
https://api.weather.gov/alerts?state=IL&effective=2018-05-20T06:08:00-04:00
你会得到一些东西:
{
"@context": [
"https://raw.githubusercontent.com/geojson/geojson-ld/master/contexts/geojson-base.jsonld",
{
"wx": "https://api.weather.gov/ontology#",
"@vocab": "https://api.weather.gov/ontology#"
}
],
"type": "FeatureCollection",
"features": [
{
"id": "https://api.weather.gov/alerts/NWS-IDP-PROD-2847567-2622897",
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-90.97,
39.39
],
[
-90.89,
39.45
],
[
-90.77,
39.38
],
[
-90.71,
39.23
],
[
-90.81,
39.22
],
[
-90.97,
39.39
]
]
]
},
推荐阅读
- python - 如何创建 Azure DevOps 管道以部署到 SharePoint?
- node.js - Electron 不尊重 `webPreferences.defaultFontFamily`?
- android - 有没有办法让我在 React Native 中创建一个文件夹并将 JSON 文件放置在 Android 和 iOS 的移动本地存储中?
- datetime - 如何以特定格式获取昨天的日期?
- asp.net-mvc - 将对象列表绑定到控制器 MVC 模型时获取 Null
- mysql - 如何在同一张桌子上加入两次?
- assembly - ARM ASM Segfaulting 在功能结束
- php - HTTP REFERER 未在 Chrome 的私人窗口中接收
- python - AttributeError: 'ShuffleDataset' 对象没有属性 'output_shapes' - 遵循 TF 教程时
- postgresql - 如何在 Postgresql 中将地球数据类型转换为 json