我有openweathermap API密钥,但我怎样才能在PHP中使用它? 和天气报告,应该从城市名称的报告,而不是从位置天气ID如何使用openweathermap API密钥?
5
A
回答
13
如何使用API密钥
以下参数添加到GET请求:APPID = APIKEY 例:api.openweathermap.org/data/2.5/forecast/city?APPID= YOURAPIKEY &你想要什么。
<?php
$request = 'http://api.openweathermap.org/data/2.5/forecast/city?APPID=***YOURAPIKEY***';
$response = file_get_contents($request);
$jsonobj = json_decode($response);
print_r($jsonobj);
?>
要请求的特定信息只要看看该API接受的按键和附加&到URL KEY = VAL的端部。
一个例子是
http://api.openweathermap.org/data/2.5/weather?APPID=YourAPIKey&q=London
我也想与API的我建议安装一个JSON插件浏览器工作时的补充。我将JSONView作为Google chrome扩展安装,非常适合查看json。
+0
谢谢马克! – 2016-01-11 22:05:50
相关问题
- 1. 如何使用OpenWeatherMap API for Javascript?
- 2. 如何使用卷曲与API密钥和API秘密检查许可密钥
- 3. 如何安全使用API密钥
- 4. 如何使用Google API密钥
- 5. 如何在Javascript中使用API密钥?
- 6. 使用Freebase的API密钥
- 7. 如何通过API密钥
- 8. 如何使api密钥更安全
- 9. YouTubePlayer - 如何隐藏/加密API密钥?
- 10. OpenWeatherMap API SWIFT
- 11. RingCentral API密钥
- 12. 使用Google Places API浏览器密钥或应用密钥REQUEST_DENIED?
- 13. 如何使用任何密钥加密
- 14. 如何通过独特的API密钥使用多个Google API
- 15. 如何使用UILaunchImages密钥
- 16. Soundcloud API密钥
- 17. 如何使用Laravel和Mandrill使用多个API密钥
- 18. 使用浏览器密钥的GCM api密钥?
- 19. Web API创建API密钥
- 20. API密钥内容加密
- 21. SAS:使用API连接到OpenWeatherMap
- 22. 的日期和时间使用openweathermap API
- 23. 使用openweathermap API进行温度转换
- 24. Regenerate linkedin API密钥
- 25. Githubmap上的Openweathermap API
- 26. openweathermap API角度ES6
- 27. 使用API密钥和秘密连接到交易API(Poloniex)
- 28. YQL:如何在yql v1/yql/* rest api调用中使用密钥?
- 29. 地图API密钥
- 30. 的Youtube API密钥
我得到 { “坐标”:{ “LON”: - 0.13, “LAT”:51.51}, “SYS”:{ “类型”:1, “ID”:5091,“信息“:0.3048,” 国 “:” 国标 “ ”日出“:1409288950, ”夕阳“:1409338405}, ”天气预报“:[{ ”ID“:500, ”主“: ”雨“, ”说明“:”小雨“,”icon“:”10n“}],”base“:”cmc站“,”main“:{”temp“:290.39,”pressure“:1013,”humidity“:77,”temp_min“: 289.15, “temp_max”:291.65}, “风”:{ “速度”:7.2, “DEG”:240}, “云”:{ “所有”:75}, “DT”:1409343901, “ID”:2643743 ,“名称”:“伦敦”,“鳕鱼”:200} 因此,如何在变量中使用“[temp] => 300.15”值来显示该值? – 2014-08-29 21:22:32
这应该重新打开。 '太宽了'我的屁股:D这是原始海报寻找的信息的完美问题。谁关闭这是严重过热:) – 2016-01-11 22:04:27