Пример #1
0
        async void getWeather(object sender, System.EventArgs e)
        {
            HttpClient client = new HttpClient();


            var uri = new Uri(string.Format(
                                  $"https://api.openweathermap.org/data/2.5/weather?q=" + $"San Marcos" + "&units=imperial"
                                  + $"&appid={API}"));

            var request = new HttpRequestMessage();

            request.Method     = HttpMethod.Get;
            request.RequestUri = uri;

            HttpResponseMessage response = await client.SendAsync(request);

            WeatherItem weatherData = null;

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();

                weatherData = WeatherItem.FromJson(content);

                BindingContext = weatherData;
                //DisplayAlert("Success", "test", "OK");
            }
        }
 public static string ToJson(this WeatherItem self) => JsonConvert.SerializeObject(self, SharpPlanner.Converter.Settings);