如何将命令字符串复制到 cgywin/curl 上的 URL?

How to replicate command string to URL on cgywin/curl?

目前我正在使用以下 url 字符串从 openweathermap.org 获取天气数据。

示例:http://api.openweathermap.org/data/2.5/weather?q=New%20York&appid={apikey}

作为回应,我收到

{"coord":{"lon":-74.01,"lat":40.71},"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}],"base":"cmc stations","main":{"temp":264.268,"pressure":1033,"humidity":53,"temp_min":264.268,"temp_max":264.268,"sea_level":1048.16,"grnd_level":1033},"wind":{"speed":1.62,"deg":73.5001},"clouds":{"all":68},"dt":1455544776,"sys":{"message":0.0048,"country":"US","sunrise":1455536990,"sunset":1455575462},"id":5128581,"name":"New York","cod":200}

我想在 cygwin/curl 上复制上面的内容。

以下是我多次失败的尝试之一。

$ curl -X POST --data "q=London&appid={apikey}" http://api.openweathermap.org/data/2.5/weather
{"cod":401, "message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."}

但是如果我直接在 URL

上使用 API 键就可以了

问题:如何使用 curl 访问此 API?

参考文献:

就是bash,是吗?我没有 API 键,但如果我有,应该可以。

OPENWEATHER_API_KEY="something"
curl "http://api.openweathermap.org/data/2.5/weather?q=New%20York&appid=$OPENWEAHTER_API_KEY"

输出

{"cod":401, "message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."}