public bool Login(string username, string pwd, out string userid, out string msg, bool md5 = true) { msg = "登录失败"; userid = ""; if (!md5) { pwd = Encrypter.EncryptMd5(pwd); } var para = string.Format("userName={0},password={1}", username, pwd); var ret = WebHelper.Get(LoginUrl, para); var reto = JsonConvert.DeserializeObject <Net965808Ret>(ret); if (reto == null) { return(false); } userid = reto.userId; msg = reto.message; return(reto.IsOk()); }
public bool Regist(string username, string pwd, out string msg, bool md5 = true) { msg = "注册失败"; var paras = new Dictionary <string, string> { { "loginId", username }, { "password", md5?pwd: Encrypter.EncryptMd5(pwd) }, { "displayName", username }, { "duty", "" }, { "mobile", "" } }; var ret = WebHelper.Get(RegisterUrl, paras); var reto = JsonConvert.DeserializeObject <Net965808Ret>(ret); if (reto == null) { return(false); } msg = reto.message; return(reto.IsOk()); }
public static string Get(string url, string postDataStr) { var request = (HttpWebRequest)WebRequest.Create(url + (postDataStr == "" ? "" : ("?" + string.Format("para={0}", HttpUtility.UrlEncode(Encrypter.EncryptDes(postDataStr)))))); request.Method = "GET"; request.ContentType = "text/html;charset=UTF-8"; var response = (HttpWebResponse)request.GetResponse(); var myResponseStream = response.GetResponseStream(); if (myResponseStream == null) { return(""); } var myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8")); var retString = myStreamReader.ReadToEnd(); myStreamReader.Close(); myResponseStream.Close(); return(retString); }