php获取城市天气API接口源码,接口调用的是微鲤的接口,2020年9月1日 10:11:07测试接口还可以正常使用。
API查询接口代码
<?php function tian(){ $city=$_GET['city']; $url="https://wthrcdn.etouch.cn/weather_mini?city=".$city; $str = file_get_contents($url); $result= gzdecode($str); //end echo $result; } tian(); ?>
接口返回数据
{"data":{"yesterday":{"date":"31日星期一","high":"高温 34℃","fx":"北风","low":"低温 24℃","fl":"<![CDATA[2级]]>","type":"晴"},"city":"武汉","forecast":[{"date":"1日星期二","high":"高温 34℃","fengli":"<![CDATA[3级]]>","low":"低温 23℃","fengxiang":"北风","type":"晴"},{"date":"2日星期三","high":"高温 32℃","fengli":"<![CDATA[2级]]>","low":"低温 20℃","fengxiang":"北风","type":"晴"},{"date":"3日星期四","high":"高温 33℃","fengli":"<![CDATA[2级]]>","low":"低温 19℃","fengxiang":"西风","type":"晴"},{"date":"4日星期五","high":"高温 33℃","fengli":"<![CDATA[2级]]>","low":"低温 21℃","fengxiang":"南风","type":"晴"},{"date":"5日星期六","high":"高温 31℃","fengli":"<![CDATA[2级]]>","low":"低温 21℃","fengxiang":"东风","type":"多云"}],"ganmao":"感冒易发期,外出请适当调整衣物,注意补充水分。","wendu":"28"},"status":1000,"desc":"OK"}
API
2022-06-15 121API是开发中必备知识点,合理的应用API可以大大节省开发成本,为您整理收集了包含API接口的信息,包含API接口,API代码,API源码,助你更快的学习使用API技术....
- 带五套模板的API接口系统源码 [2024-01-18]
- layui框架API接口调用管理系统源码 [2024-01-16]
- 小西瓜API管理系统源码2.0 [2023-12-07]
- ApiDebug在线api接口调试浏览器插件 [2023-12-07]
- 抖音短视频去水印官方API接口源码 [2023-10-04]