/// <summary> /// 登录DZ /// </summary> /// <param name="Url">logging.php地址.请附带?action=login添加</param> /// <param name="LoginName">登录名(用户名、邮箱或者uid)</param> /// <param name="LoginNameType">登录名类型(用户名、邮箱或者uid)</param> /// <param name="Password">密码</param> /// <param name="VCode">验证码(暂时未支持)</param> /// <param name="Questionid">登录提示问题id</param> /// <param name="Answer">答案</param> /// <param name="Charset">网页编码</param> /// <param name="Proxy">代理(不使用请传入null)</param> /// <returns></returns> public static CookieContainer Login(string Url, string LoginName, LoginNameType LoginType, string Password, string VCode, string Questionid, string Answer, string Charset, WebProxy Proxy) { string returnData = ""; string formhash = ""; CookieContainer objCookie = new CookieContainer(); Httper objPostHttper = new Httper(); objPostHttper.Url = Url; objPostHttper.Charset = Charset; objPostHttper.Cookie = objCookie; if (Proxy != null) { objPostHttper.Proxy = Proxy; } try { formhash = RegexUtility.GetMatch(objPostHttper.HttpGet(), "formhash=(.*)\""); objPostHttper.PostData = string.Format("&formhash={0}&referer=index.php&loginfield={5}&username={1}&password={2}&questionid={3}&answer={4}&cookietime=2592000&loginsubmit=%CC%E1%BD%BB" , formhash, LoginName, Password, Questionid, Answer, LoginType.ToString().ToLower()); returnData = objPostHttper.HttpPost(); if (returnData.IndexOf("欢迎您回来") > 0) { //登录成功,返回cookie return(objCookie); } } catch (Exception ex) { throw ex; } return(null); }
/// <summary> /// ��¼DZ /// </summary> /// <param name="Url">logging.php��ַ.�븽��?action=login���</param> /// <param name="LoginName">��¼�����û������������uid��</param> /// <param name="LoginNameType">��¼�����ͣ��û������������uid��</param> /// <param name="Password">����</param> /// <param name="VCode">��֤��(��ʱδ֧��)</param> /// <param name="Questionid">��¼��ʾ����id</param> /// <param name="Answer">��</param> /// <param name="Charset">��ҳ����</param> /// <param name="Proxy">����(��ʹ���봫��null)</param> /// <returns></returns> public static CookieContainer Login(string Url, string LoginName, LoginNameType LoginType, string Password, string VCode, string Questionid, string Answer, string Charset, WebProxy Proxy) { string returnData = ""; string formhash = ""; CookieContainer objCookie = new CookieContainer(); Httper objPostHttper = new Httper(); objPostHttper.Url = Url; objPostHttper.Charset = Charset; objPostHttper.Cookie = objCookie; if (Proxy != null) { objPostHttper.Proxy = Proxy; } try { formhash = RegexUtility.GetMatch(objPostHttper.HttpGet(), "formhash=(.*)\""); objPostHttper.PostData = string.Format("&formhash={0}&referer=index.php&loginfield={5}&username={1}&password={2}&questionid={3}&answer={4}&cookietime=2592000&loginsubmit=%CC%E1%BD%BB" , formhash, LoginName, Password, Questionid, Answer, LoginType.ToString().ToLower()); returnData = objPostHttper.HttpPost(); if (returnData.IndexOf("��ӭ������") > 0) { //��¼�ɹ�,����cookie return objCookie; } } catch (Exception ex) { throw ex; } return null; }
/// <summary> /// accessToken过期时,更新模板消息api /// </summary> /// <param name="publicAccountID">公众号</param> private static void UpdateTemplateMessageBaseUrl(string apiBaseUrl, int publicAccountID) { string url = string.Format("{0}/api/zcooApi/UpdateTemplateMessageBaseUrl", apiBaseUrl); string data = string.Format("publicAccountID={0}", publicAccountID); for (int i = 0; i < 3; i++) { var result = Httper.Post(url, data); if (result == "OK") { break; } } }
///////////////////////////////////////////////////////////// #region Component Designer generated code private void InitializeComponent() { components = new System.ComponentModel.Container(); httper = new Httper(); }