public async Task <Weather> GetCityWeather(string key) { // http://dataservice.accuweather.com/currentconditions/v1/215613?apikey=qiLiilQeNDyI0JIQukEn8VY3IcNuA8QR; Weather weather = new Weather(); JArray jdatas; string url = "http://dataservice.accuweather.com/currentconditions/v1/" + key + "?apikey=" + ConnectionStrings.GetApiKey(); using (HttpClient client = new HttpClient()) { string data = await client.GetStringAsync(url); jdatas = JArray.Parse(data); } foreach (JObject jdata in jdatas) { weather = createDataCityWeather(jdata, key); } return(weather); }
public async Task <List <City> > GetCityCode(string city) { //http://dataservice.accuweather.com/locations/v1/cities/autocomplete?apikey=qiLiilQeNDyI0JIQukEn8VY3IcNuA8QR&q=Ashdod&language=en-us List <City> cities = new List <City>(); JArray jdatas; string url = "http://dataservice.accuweather.com/locations/v1/cities/autocomplete?apikey=" + ConnectionStrings.GetApiKey() + "&q=" + city + "&language=" + "en-us"; using (HttpClient client = new HttpClient()) { string data = await client.GetStringAsync(url); jdatas = JArray.Parse(data); } foreach (JObject jdata in jdatas) { cities.Add(createDataCity(jdata)); } return(cities); }