Guest User

Untitled

a guest
Apr 22nd, 2018
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.00 KB | None | 0 0
  1. public static string[] Login(string email, string password2)
  2.         {
  3.  
  4.             Uri address = new Uri(Properties.Settings.Default.WHMCS_URL + "includes/api.php");
  5.  
  6.             // Create the web request  
  7.             HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
  8.  
  9.             // Set type to POST  
  10.             request.Method = "POST";
  11.             request.ContentType = "application/x-www-form-urlencoded";
  12.  
  13.             string Wusername = Properties.Settings.Default.WHMCS_Username;
  14.             string Wpassword = Properties.Settings.Default.WHMCS_Password;
  15.  
  16.             string action = "validatelogin";
  17.  
  18.             StringBuilder data = new StringBuilder();
  19.  
  20.             data.Append("username=" + HttpUtility.UrlEncode("api"));
  21.             data.Append("&password=" + HttpUtility.UrlEncode(GetMd5Sum("api")));
  22.             data.Append("&action=" + HttpUtility.UrlEncode(action));
  23.             data.Append("&email=" + HttpUtility.UrlEncode("luke@axxim.net"));
  24.             data.Append("&password2=" + HttpUtility.UrlEncode("1018"));
  25.  
  26.             // Create a byte array of the data we want to send  
  27.             byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());
  28.  
  29.             // Set the content length in the request headers  
  30.             request.ContentLength = byteData.Length;
  31.  
  32.             // Write data  
  33.             using (Stream postStream = request.GetRequestStream())
  34.             {
  35.                 postStream.Write(byteData, 0, byteData.Length);
  36.             }
  37.  
  38.             // Get response  
  39.             using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
  40.             {
  41.                 StreamReader reader = new StreamReader(response.GetResponseStream());
  42.  
  43.                 string TheReturn = reader.ReadToEnd();
  44.  
  45.                 string[] RequestReturn = TheReturn.Split(new string[] { ";" }, StringSplitOptions.None);
  46.                 Console.WriteLine(RequestReturn[0]);
  47.  
  48.                 return RequestReturn;
  49.             }
  50.  
  51.  
  52.         }
Add Comment
Please, Sign In to add comment