Пример #1
0
        private static WeatherAPIEntity GetCityWeather(string cityName = "上海")
        {
            WeatherAPIEntity entity = new WeatherAPIEntity();

            try
            {
                System.Net.HttpWebResponse response = HttpWebResponseUtility.CreateGetHttpResponse("http://wthrcdn.etouch.cn/weather_mini?city=" + $"{HttpUtility.UrlEncode(cityName)}", null, null, null);
                string jsonString = HttpWebResponseUtility.getResponseString(response);
                entity = JsonConvert.DeserializeObject <WeatherAPIEntity>(jsonString);
            }
            catch { }
            return(entity);
        }