Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Include these two imports
- //using System.Net;
- //using System.Net.Http;
- //using System.Threading.Task; (might be Tasks)
- try
- {
- //Obviously u wanna configure this to work in ur program
- string Username = "aids";
- using (HttpClientHandler handler = new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate })
- using (HttpClient client = new HttpClient(handler))
- using (HttpRequestMessage request = new HttpRequestMessage() { Method = HttpMethod.Get, RequestUri = new Uri("https://api.twitch.tv/kraken/users/" + Username + "?client_id=xxxx") })
- {
- //Only use this one if ur not comfortable with async shit all you have to do is make the function async
- //e.g. private async Task<bool> SuccMyToes() . <--- Change the bool to string or w/e if u want to
- //return a string or just change to to Task if u dont want to return anything :)
- //var response = client.SendAsync(request).GetAwaiter().GetResult();
- var response = await client.SendAsync(request);
- if(response.StatusCode.ToString() == "422")
- {
- //Banned
- Console.WriteLine("Banned");
- }
- else if (response.StatusCode == HttpStatusCode.OK)
- {
- //In User
- Console.WriteLine("In use");
- }
- else
- {
- Console.WriteLine("Available");
- //Available
- }
- }
- }
- catch (Exception ex) { Console.WriteLine(ex.Message); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement