Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string[] Login(string email, string password2)
- {
- Uri address = new Uri(Properties.Settings.Default.WHMCS_URL + "includes/api.php");
- // Create the web request
- HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
- // Set type to POST
- request.Method = "POST";
- request.ContentType = "application/x-www-form-urlencoded";
- string Wusername = Properties.Settings.Default.WHMCS_Username;
- string Wpassword = Properties.Settings.Default.WHMCS_Password;
- string action = "validatelogin";
- StringBuilder data = new StringBuilder();
- data.Append("username=" + HttpUtility.UrlEncode("api"));
- data.Append("&password=" + HttpUtility.UrlEncode(GetMd5Sum("api")));
- data.Append("&action=" + HttpUtility.UrlEncode(action));
- data.Append("&email=" + HttpUtility.UrlEncode("luke@axxim.net"));
- data.Append("&password2=" + HttpUtility.UrlEncode("1018"));
- // Create a byte array of the data we want to send
- byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());
- // Set the content length in the request headers
- request.ContentLength = byteData.Length;
- // Write data
- using (Stream postStream = request.GetRequestStream())
- {
- postStream.Write(byteData, 0, byteData.Length);
- }
- // Get response
- using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
- {
- StreamReader reader = new StreamReader(response.GetResponseStream());
- string TheReturn = reader.ReadToEnd();
- string[] RequestReturn = TheReturn.Split(new string[] { ";" }, StringSplitOptions.None);
- Console.WriteLine(RequestReturn[0]);
- return RequestReturn;
- }
- }
Add Comment
Please, Sign In to add comment