Advertisement
atillabyte

GetToken

Jul 5th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.89 KB | None | 0 0
  1.  
  2.     public class PlayerIOToken
  3.     {
  4.         public static string SimpleGet(string UsernameOrEmail, string Password) {
  5.             return Get(UsernameOrEmail, Password, "400");
  6.         }
  7.         public static string KongGet(string UserID, string GameAuthToken) {
  8.             return Get(UserID, GameAuthToken, "412");
  9.         }
  10.         public static string FBGet(string AuthToken) {
  11.             return Get("", AuthToken, "418");
  12.         }
  13.  
  14.         public static string Get(string UsernameOrEmail, string Password, string URI)
  15.         {
  16.            
  17.             char ESep = '';
  18.             HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://api.playerio.com/api/"+URI);
  19.             req.Proxy = null;
  20.             string request = null;
  21.             if (URI != "418")
  22.             {
  23.                 request = (char)0x0A + "&everybody-edits-su9rn58o40itdbnw69plyw" + (char)UsernameOrEmail.Length + UsernameOrEmail + ESep + (char)Password.Length + Password;
  24.             }
  25.             else { request = (char)0x0A + "&everybody-edits-su9rn58o40itdbnw69plyw" + (char)Password.Length + Password; }
  26.             req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded";
  27.             byte[] bytes = Encoding.UTF8.GetBytes(request);
  28.             req.ContentLength = bytes.Length;
  29.             Stream requestStream = req.GetRequestStream();
  30.             requestStream.Write(bytes, 0, bytes.Length);
  31.             WebResponse response = req.GetResponse();
  32.             Stream stream = response.GetResponseStream();
  33.             StreamReader reader = new StreamReader(stream);
  34.             var result = reader.ReadToEnd();
  35.             Token = System.Text.RegularExpressions.Regex.Match(result, @"(?<=\"+(char)0x0A+@")(.*?)(?=\"+(char)0x12+")").Value;
  36.             stream.Dispose();
  37.             reader.Dispose();
  38.             return Token;
  39.         }
  40.         public static string Token;
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement