Last active
December 15, 2015 03:59
-
-
Save bertt/5197922 to your computer and use it in GitHub Desktop.
Portable Class Libraries and webservices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GeonamesApi | |
{ | |
public Earthquake[] GetEarthquakes() | |
{ | |
var client = new HttpClient(); | |
client.BaseAddress = new Uri("http://api.geonames.org/"); | |
var response = client.GetAsync("earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=bertt").Result; | |
var earthquakesJson = response.Content.ReadAsStringAsync().Result; | |
var rootobject = JsonConvert.DeserializeObject<Rootobject>(earthquakesJson); | |
return rootobject.earthquakes; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Rootobject | |
{ | |
public Earthquake[] earthquakes { get; set; } | |
} | |
public class Earthquake | |
{ | |
public string eqid { get; set; } | |
public float magnitude { get; set; } | |
public float lng { get; set; } | |
public string src { get; set; } | |
public string datetime { get; set; } | |
public float depth { get; set; } | |
public float lat { get; set; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed partial class MainPage : Page | |
{ | |
public MainPage() | |
{ | |
this.InitializeComponent(); | |
} | |
protected override void OnNavigatedTo(NavigationEventArgs e) | |
{ | |
var names = new GeonamesApi().GetEarthquakes(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment