Flurl
In case you haven’t check out flurl, you should ;). It’s a great way to create web clients / url’s.
Here’s an example that uses the Blizzard API for world of warcraft.
string url = "https://eu.api.battle.net/";
var wowResponse = await url
.AppendPathSegments("wow", "character", "Aggramar", "Morphea")
.SetQueryParam("fields", "hunterPets")
.SetQueryParam("locale", "en_GB")
.SetQueryParam("apikey", "APIKEY")
.GetAsync();
var content = await wowResponse.Content.ReadAsStringAsync();
clsHunter hunterInfo = JsonConvert.DeserializeObject(content);
if (hunterInfo.hunterPets != null)
{
foreach (var item in hunterInfo.hunterPets)
{
Console.WriteLine("Pet name : " + item.name);
}
}
Looks great doesn’t it ? ;).
Comments are closed.