Created
April 7, 2015 03:04
-
-
Save angelobelchior/3420ec1987706a6de91c to your computer and use it in GitHub Desktop.
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 GitHubApi | |
{ | |
public async Task<List<string>> GetAsync(string user) | |
{ | |
string url = string.Format("https://api.github.com/users/{0}/repos", user); | |
var client = new HttpClient(); | |
client.DefaultRequestHeaders.Add("User-Agent", "Other"); | |
var response = await client.GetAsync(url); | |
var content = await response.Content.ReadAsStringAsync(); | |
var json = JArray.Parse(content); | |
var repositories = new List<string>(); | |
foreach (var item in json) { | |
var repository = item.Value<string>("full_name"); | |
repositories.Add(repository); | |
} | |
return repositories; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment