Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System.Net;
- using System.IO;
- namespace ReadRusselAPI
- {
- class Program
- {
- static void Main(string[] args)
- {
- try
- {
- HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://ee-api.lrussell.net/player/lrussell");
- req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0";
- req.Method = "GET";
- req.ContentType = "application/json";
- try
- {
- using (HttpWebResponse response = req.GetResponse() as HttpWebResponse)
- {
- if (response.StatusCode != HttpStatusCode.OK)
- {
- throw new Exception("Error: " + response.StatusCode + " " + response.StatusDescription);
- }
- else
- {
- using (StreamReader reader = new StreamReader(response.GetResponseStream()))
- {
- String text = reader.ReadToEnd();
- var datta = JsonConvert.DeserializeObject<player>(text);
- foreach (KeyValuePair<string,string> kvp in datta.Worlds)
- {
- Console.WriteLine("ID: " + kvp.Key + " Title: " + kvp.Value);
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- Console.ReadKey();
- }
- }
- public class player
- {
- public string Name { get; set; }
- public string Id { get; set; }
- public int MaximumEnergy { get; set; }
- public int CurrentEnergy { get; set; }
- public int Gems { get; set; }
- public string LastLogin { get; set; }
- public string LastMagicCoin { get; set; }
- public int LoginStreak { get; set; }
- public int TotalItems { get; set; }
- public int Smiley { get; set; }
- public int TimeZone { get; set; }
- public bool Visible { get; set; }
- public string Banned { get; set; }
- public string TempBanned { get; set; }
- public string HasBeta { get; set; }
- public string IsGold { get; set; }
- public string IsModerator { get; set; }
- public string IsAdministrator { get; set; }
- public Dictionary<string,string> Worlds { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement