public
Last active

  • Download Gist
gistfile1.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
async Task ShowStuffAsync ()
{
var client = new HttpClient ();
 
var content = JsonValue.Parse (await client.GetStringAsync ("http://api.worldbank.org/countries?format=json"));
int number_of_countries = content [0] ["per_page"];
int done = 0, error = 0;
 
CountriesLabel.Text = string.Format ("Countries: {0} done: 0 error: 0", number_of_countries);
 
foreach (JsonObject c in content [1]) {
try {
string country_url = string.Format ("http://api.worldbank.org/countries/{0}/indicators/NY.GDP.MKTP.CD&format=json", (string)c ["id"]);
var json = JsonValue.Parse (await client.GetStringAsync (country_url));
var map = await LoadCountryLogoAsync (json ["name"]);
if (map != null){
var position = await LookupCountryPositionAsync (c ["longitude"], c ["latitude"]);
if (position != null){
AddPin (map, position);
status.Text = json ["name"];
++done;
}
}
 
} catch (Exception e) {
++error;
status.Text = "Got exception "+ e;
}
CountriesLabel.Text = string.Format ("Countries: {0} done: {1} error: {2}", number_of_countries, done, error);
}
CountriesLabel.Text = string.Format ("Countries: {0}", number_of_countries);
}

s/&/?/

http://api.worldbank.org/countries/{0}/indicators/NY.GDP.MKTP.CD?format=json

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.