Exemplo n.º 1
0
        private WeatherData GetResponseFromWeather(CityForSearch result)
        {
            string url = "http://api.openweathermap.org/data/2.5/weather?id=" + result.id + "&appid=" + appid;

            WebRequest request = WebRequest.Create(url);

            Debug.Print(request.ToString());
            request.Method = "POST";

            request.ContentType = "application/x-www-urlencoded";

            WebResponse response = request.GetResponse();

            string answer;

            using (Stream s = response.GetResponseStream())
            {
                using (StreamReader reader = new StreamReader(s))
                {
                    answer = reader.ReadToEnd();
                }
            }
            response.Close();

            var WeathData = JsonConvert.DeserializeObject <WeatherData>(answer);

            WeathData = translate.Interpretate(WeathData);


            return(WeathData);
        }
Exemplo n.º 2
0
        } //create database with ua loc

        internal WeatherData FindCity(string city)
        {
            if (city == null)
            {
                city = "Zhytomyr";
            }
            string url = "http://api.openweathermap.org/data/2.5/weather?q=" + city + "&appid=" + appid;

            WebRequest request = WebRequest.Create(url);

            Debug.Print(request.ToString());
            request.Method = "POST";

            request.ContentType = "application/x-www-urlencoded";

            WebResponse response = request.GetResponse();

            string answer;

            using (Stream s = response.GetResponseStream())
            {
                using (StreamReader reader = new StreamReader(s))
                {
                    answer = reader.ReadToEnd();
                }
            }
            response.Close();

            var WeathData = JsonConvert.DeserializeObject <WeatherData>(answer);

            translate = Transliter.GetInstance();
            WeathData = translate.Interpretate(WeathData);



            return(WeathData);
        }