使用人数:123人
国内城市天气指数

  1. 接口介绍: 查询国内城市天气常用指数(空气指数,湿度指数,风向指数,日出日落时间等数据)
  2. 接口地址: http://open-api-life.luzhi.online/getweatheraqiinfo
  3. 请求方式: GET
  4. 返回格式: JSON
  5. 请求参数说明:
    名称 必须 类型 说明
    token String 接口调用授权签名
    cityname 必须 String 城市名称
  6. 请求示例:
    http://open-api-life.luzhi.online/getweatheraqiinfo?city=北京&token=***
  7. 返回参数:
    名称 类型 说明
    code int 响应码。成功为200,其余参见接口调用响应码表
    msg String 返回消息。成功返回Succeed。其余错误消息为对应错误码的提示。
    data Object 返回数据。数据类型为Json格式的Object
    data数据说明:
    weather_light String 白天天气
    temperature_data_low String 最低温
    temperature_data_high String 最高温
    air_data String 天气指数
    humidity_data String 湿度指数
    wind_data String 风向指数
    sunset_data_out String 日出时间
    sunset_data_in String 日落时间
  8. 正确返回示例:
    {
        "code": 200, 
        "message": "Succeed", 
        "data": {
            "weather_night": "晴", 
            "weather_light": "晴", 
            "temperature_data_low": "4", 
            "temperature_data_high": "20", 
            "air_data": "35(优)", 
            "humidity_data": "71%", 
            "wind_data": "北风,一级", 
            "sunset_data_out": "06:40", 
            "sunset_data_in": "17:15", 
            "status": "ok"
        }
    }
  9. 错误返回示例:
    {
      "code": 401,
      "message": "Sign is error",
      "data": null
    }
  10. 参考代码:

    
            //using System.IO;
            //using System.Text;
            //using System.Net;
            //using System.Net.Security;
            static void Main(string[] args)
            {
                String method = "GET";
                String url = "http://open-api-life.luzhi.online/getweatheraqiinfo?city=北京&token=***";
                HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(url); 
                httpRequest.Method = method;
                try
                {
                    HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
                    Stream st = httpResponse.GetResponseStream();
                    StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
                    Console.WriteLine(reader.ReadToEnd());
                    Console.WriteLine("\n");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
                                                 

     
         
        public static void main(String[] args) throws IOException
        { 
            String url = "http://open-api-life.luzhi.online/getweatheraqiinfo?city=北京&token=***";
        
            HttpClient httpClient = HttpClients.custom().build();
            HttpGet get = new HttpGet(url);
        
            HttpResponse response = httpClient.execute(get);
            HttpEntity resp_entity = response.getEntity();
            resp_entity.getContent();
        
            String resp_content = EntityUtils.toString(resp_entity,StandardCharsets.UTF_8);
        
            System.out.println(resp_content);
        } 
                                             

    
        import json, urllib
        from urllib import urlencode
    
        url = "http://*****"
        params = { 
            "token": "*************",     # 授权签名 
            "param1":"……"               # 参数1                                       
        }
        params = urlencode(params)
        f = urllib.urlopen(url, params)
        content = f.read()
        res = json.loads(content)
        if res:
            print(res)
        else:
            print("请求异常")