Home > Backend Development > PHP Tutorial > 获取接口的参数

获取接口的参数

WBOY
Release: 2016-06-23 13:16:37
Original
1358 people have browsed it

接口如下:
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));
Copy after login
{"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":"北京"}}

谢版主!!!!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template