尽管包含必要的参数,但 OpenWeatherMap 不返回指标
OpenWeatherMap not returning metric despite having included necessary parameter
我正在编写一些使用 OpenWeatherMap API 的代码。我需要我的数据以摄氏度为单位,所以我在他们的网站上包含了必要的 &units=metric
。
api.openweathermap.org/data/2.5/weather?id=XXX&appid=XXX&units=metric
然而,这个returns:
{"error": "404"}
此外,我尝试不包含 &units=metric
参数,一切正常。
那么问题到底是什么?
看起来不允许在这种类型的 api 调用中使用单位参数。
您需要在这样的调用中使用它:
samples.openweathermap.org/data/2.5/find?q=London&units=metric&appid=xxx
如果您将 /find 更改为 /weather,您将得到 404,如果您更改 q 也会得到相同结果=伦敦 id=524901
所以我认为最好以华氏度为单位获取温度,然后使用公式将其转换为摄氏度:
(X°F - 32) × 5/9 = Y°C
我正在编写一些使用 OpenWeatherMap API 的代码。我需要我的数据以摄氏度为单位,所以我在他们的网站上包含了必要的 &units=metric
。
api.openweathermap.org/data/2.5/weather?id=XXX&appid=XXX&units=metric
然而,这个returns:
{"error": "404"}
此外,我尝试不包含 &units=metric
参数,一切正常。
那么问题到底是什么?
看起来不允许在这种类型的 api 调用中使用单位参数。
您需要在这样的调用中使用它: samples.openweathermap.org/data/2.5/find?q=London&units=metric&appid=xxx
如果您将 /find 更改为 /weather,您将得到 404,如果您更改 q 也会得到相同结果=伦敦 id=524901
所以我认为最好以华氏度为单位获取温度,然后使用公式将其转换为摄氏度:
(X°F - 32) × 5/9 = Y°C