获取接口的参数

WBOY
發布: 2016-06-23 13:16:37
原創
1350 人瀏覽過

接口如下:
http://wthrcdn.etouch.cn/weather_mini?city=北京

从浏览器上直接输入可以获取返回值
但自己用了file_get_contents(),fopen()以及curl都获取不到返回值
初学,不知道是不是自己用法的问题。


回复讨论(解决方案)


$url = 'http://wthrcdn.etouch.cn/weather_mini?city=%E5%8C%97%E4%BA%AC';echo gzdecode(file_get_contents($url));
登入後複製
{"desc":"OK","status":1000,"data":{"wendu":"8","ganmao":"昼夜温差很大,易发生感冒,请注意适当增减衣服,加强自我防护避免感冒。","forecast":[{"fengxiang":"北风","fengli":"3-4级","high":"高温 9℃","type":"晴","low":"低温 -4℃","date":"16日星期二"},{"fengxiang":"无持续风向","fengli":"微风级","high":"高温 9℃","type":"晴","low":"低温 -2℃","date":"17日星期三"},{"fengxiang":"北风","fengli":"3-4级","high":"高温 9℃","type":"晴","low":"低温 -2℃","date":"18日星期四"},{"fengxiang":"北风","fengli":"3-4级","high":"高温 7℃","type":"多云","low":"低温 -2℃","date":"19日星期五"},{"fengxiang":"无持续风向","fengli":"微风级","high":"高温 3℃","type":"晴","low":"低温 -5℃","date":"20日星期六"}],"yesterday":{"fl":"3-4级","fx":"北风","high":"高温 5℃","type":"晴","low":"低温 -4℃","date":"15日星期一"},"aqi":"41","city":"北京"}}

谢版主!!!!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板