Skip to content

Flurl

August 12, 2016
tags:

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 ? ;).

Advertisements

Comments are closed.

%d bloggers like this: