private async Task LoadVenue(string id) { Uri uri = new Uri("https://api.foursquare.com/v2/venues/" + id + "?client_id=" + App.foursquareClientId + "&client_secret=" + App.foursquareClientSecret + " &v=20160508"); HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Add("Accept", "application/json"); HttpResponseMessage response = await httpClient.GetAsync(uri); string jsonString = await response.Content.ReadAsStringAsync(); VenueResult result = JsonConvert.DeserializeObject <VenueResult>(jsonString); if (result.meta != null) { ProgressRingVenues.IsActive = false; ProgressRingVenues.Visibility = Visibility.Collapsed; if (result.meta.code == 200 && result.response.venue != null) { DisplayVenue(result.response.venue); } else if (result.meta.errorDetail != null) { DisplayErrorMessage(result.meta.errorDetail); } else { StackPanelError.Visibility = Visibility.Visible; } } }
private async Task LoadVenuesList() { Uri uri; if (searchParams.latlon != null) { uri = new Uri("https://api.foursquare.com/v2/venues/explore?client_id=" + App.foursquareClientId + "&client_secret=" + App.foursquareClientSecret + " &v=20160508&ll=" + searchParams.latlon + "§ion=" + searchParams.query); } else { uri = new Uri("https://api.foursquare.com/v2/venues/explore?client_id=" + App.foursquareClientId + "&client_secret=" + App.foursquareClientSecret + " &v=20160508&near=" + searchParams.cityName + "§ion=" + searchParams.query); } HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Add("Accept", "application/json"); HttpResponseMessage response = await httpClient.GetAsync(uri); string jsonString = await response.Content.ReadAsStringAsync(); VenueResult result = JsonConvert.DeserializeObject <VenueResult>(jsonString); if (result.meta != null) { ProgressRingVenues.IsActive = false; ProgressRingVenues.Visibility = Visibility.Collapsed; if (result.meta.code == 200) { GridFlights.Visibility = Visibility.Visible; if (searchParams.latlon == null && result.response.geocode != null) { if (result.response.geocode != null) { TextBlockTitle.Text = "Exploring " + searchParams.categoryName + " in " + result.response.geocode.displayString; cityName = result.response.geocode.displayString; } else { TextBlockTitle.Text = "Exploring " + searchParams.categoryName + " in " + result.response.headerFullLocation; cityName = result.response.headerFullLocation; } TextBlockMessage.Text = "Check out flights to " + cityName + "!"; } DisplayVenuesList(result.response); } else if (result.meta.errorDetail != null) { DisplayErrorMessage(result.meta.errorDetail); } else { StackPanelError.Visibility = Visibility.Visible; } } }