调用天气接口

 function tian(){

    $city=$_GET['city']; //接收城市名
 
    $url="http://wthrcdn.etouch.cn/weather_mini?city=".$city
    $str file_get_contents($url);  //调用接口获得天气数据
    //这一步很重要
    $result= gzdecode($str);   //解压
    //end
    echo  $result;
 
   }
返回出来的数据为天气
posted @ 2021-03-04 18:31  我想再睡一会  阅读(117)  评论(0)    收藏  举报