public Form1()
 {
     InitializeComponent();
     m_webPost = new ClassHttpPost();
     textBox2.Text = "*****@*****.**";
     textBox3.Text = "123456";
 }
 public static void FreshProc()
 {
     //ע��ɹ�
     int i = 0;
     for (; ; )
     {
         i++;
         lock (m_objTest)
         {
             m_iRegNum--;
             if (m_iRegNum < 1)
             {
                 return;
             }
         }
         ClassHttpPost webPost = new ClassHttpPost();
         string strUser = "******" + new Random().Next(5000).ToString() + i.ToString();
         string strData = string.Format("username={0}&email={0}1@{0}.com&password=jjkad123&confirm_password=jjkad123&other%5Bmsn%5D=&other%5Bqq%5D=&other%5Boffice_phone%5D=&other%5Bhome_phone%5D=&other%5Bmobile_phone%5D=&way=3&othertxt=&agreement=1&act=act_register&Submit=",
             strUser
             );
         string strRet = webPost.GetHttpPage("http://www.ibeifeng.com/user.php",
                 "gb2312", "POST", "", strData,
                 "http://www.ibeifeng.com/user.php?act=register",
                 "*/*", "");
         if (strRet.IndexOf("ע��ɹ�") > 0)
         {
             Console.WriteLine(string.Format("{0}: {1}", m_iRegNum, strUser));
         }
     }
 }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            ListView listView1 = FindViewById<ListView>(Resource.Id.listView1);
            items = new string[] { "Fruits", "Flower Buds"};
            listView1.Adapter = new ArrayAdapter<String>(this, Android.Resource.Layout.SimpleListItem1, items);
            listView1.ItemClick += new EventHandler<ListView.ItemClickEventArgs>(OnListItemClick);
            Spinner spinner = FindViewById<Spinner>(Resource.Id.spinner1);
            spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
            var adapter = ArrayAdapter.CreateFromResource(
                    this, Resource.Array.planets_array, Android.Resource.Layout.SimpleSpinnerItem);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinner.Adapter = adapter;

            Button mybutton1 = FindViewById<Button>(Resource.Id.MyButton1);

            mybutton1.Click += delegate
            {

                TextView textView1 = FindViewById<TextView>(Resource.Id.textView1);
                textView1.Text = "正在获取数据,请稍后......";
                ClassHttpPost webPost = new ClassHttpPost();
                webPost.GetHttpPageAsyc("http://www.web1800.com/web1800/hello.html", "utf-8", "GET", "", "", "", "*/*", "", response =>
                {
                    RunOnUiThread(() =>
                    {
                        textView1.Text = "网络访问返回结果:" + response;
                    });
                });
            };
            Button button1 = FindViewById<Button>(Resource.Id.button1);

            button1.Click += delegate
            {
                WebView webView = FindViewById<WebView>(Resource.Id.webView1);
                webView.LoadUrl(@"http://www.baidu.com");
            };
        }
        public bool Login(ClassHttpPost webPost, string strAcc,string strPwd, ref string strError, bool bForceValidate)
        {
            strError = "";
            string strUrl = "https://login.vancl.com/login/login.aspx?http://www.vancl.com/";
            string strRet = webPost.GetHttpPage(strUrl, "utf-8", "get", "", "", "", "*/*", "");
            if (strRet.IndexOf("会员登录") < 0)
            {
                strError = "加载登录页面失败";
                return false;
            }
            string strCheckCode = "";
            strRet = strRet.ToLower();

            /*
             <p id='pValidate' style="display:none"><label>验证码:</label><input maxlength="6" style="width:60px;"  id="calculatevalidate" name="calcultatevalidate" type="text" class="inputtextcolor" value=""  />
                <img id='img_validate' oldsrc='/Controls/CalculateValidateCode.ashx?key=Login' style="vertical-align:middle" /><a href="javascript:void(0)">换一题</a>
                </p>
             */

              //          var errortimes = 'true' == 'true';
            //var usererrortimesshow = 'true' == 'true';

            string strFlag1 = "var errortimes = 'true' == 'true'";
            string strFlag2 = "usererrortimesshow = 'true' == 'true'";

            if (bForceValidate || strRet.IndexOf(strFlag1) > 0 || strRet.IndexOf(strFlag2) > 0)
            {
                string strUrlCheckCode = string.Format("https://login.vancl.com/Controls/CalculateValidateCode.ashx?key=Login&t=={0}", DateTime.Now.ToFileTime()); ;
                string strReffer = "https://login.vancl.com/login/login.aspx?http://www.vancl.com/";
                if (!GetCheckCode(webPost, strAcc, out strError, out strCheckCode, strUrlCheckCode, strReffer))
                {
                    strError = "获取验证码失败";
                    return false;
                }
            }
            string strData = string.Format("Loginasync=true&LoginUserName={0}&UserPassword={1}&Validate={2}&type=web",
                strAcc,
                strPwd,
                strCheckCode);
            strUrl = "https://login.vancl.com/login/XmlCheckUserName.ashx";
            strRet = webPost.GetHttpPage(strUrl,
                "utf-8", "post", "", strData,
                "https://login.vancl.com/login/login.aspx?http://www.vancl.com/",
                "*/*", "");
            if (strRet != "")
            {
                //{"ErrorType":1,"Error":"登录信息和密码不匹配","ShowValidate":0}
                if (strRet.IndexOf("Error\":\"") > 0)
                {
                    strError = GetKeyString(strRet, "Error\":\"", "\"");
                    return false;
                }
            }
            strUrl = string.Format("http://my.vancl.com/user/getusernamebycookie?_={0}", DateTime.Now.ToFileTime());
            strRet = webPost.GetHttpPage(strUrl, "utf-8", "get", "", "", "", "*/*", "");
            string strFlag = "getUserName='" + strAcc.Substring(0, 5);
            if (strRet.IndexOf(strFlag) > 0)
                return true;
            strError = "提交登录信息出错";
            //获取页面成功
            return false;
        }
        public bool GetImage(ClassHttpPost webPost, string strFile, out string strError, string strUrl, string strReffer)
        {
            strError = "";
            try
            {
                Stream stream = webPost.GetHttpPageSteam(strUrl, "gb2312", "get", "", "", strReffer, "*/*", "");
                if (stream == null)
                {
                    strError = "获取验证码失败,网络错误";
                    return false;
                }

                List<byte> list = new List<byte>();
                while (true)
                {
                    int data = stream.ReadByte();
                    if (data == -1)
                        break;
                    list.Add((byte)data);
                }
                byte[] bytes = list.ToArray();
                if (File.Exists(strFile))
                {
                    File.Delete(strFile);
                }
                FileStream fs = new FileStream(strFile, FileMode.Create);
                BinaryWriter bw = new BinaryWriter(fs);
                bw.Write(bytes);
                bw.Close();
                fs.Close();
                return true;
            }
            catch
            {
                strError = "获取验证码失败,获取异常";
                return false;
            }
        }
 public bool GetCheckCode(ClassHttpPost webPost, string strAcc, out string strError, out string strCheckCode, string strUrl, string strReffer)
 {
     string strDirect = System.AppDomain.CurrentDomain.BaseDirectory + "pic";
     if (!Directory.Exists(strDirect))
     {
         Directory.CreateDirectory(strDirect);
     }
     string strFile = string.Format("{0}\\{1}_{2}.bmp", strDirect, strAcc, DateTime.Now.ToFileTime());
     bool bRet = GetImage(webPost, strFile, out strError, strUrl, strReffer);
     strCheckCode = "";
     if (bRet)
     {
         lock (m_hLockTable)
         {
             GetCodeHandler _myInvoke = new GetCodeHandler(GetCode);
             strCheckCode = (string)this.Invoke(_myInvoke, new object[] { strFile });
         }
     }
     else
     {
         strError = "获取验证码失败";
         return false;
     }
     return true;
 }
        //sohu reg
        private void button2_Click(object sender, EventArgs e)
        {
            _GoodsFreshStr goodInfo = new _GoodsFreshStr();
            goodInfo.strAcc = "testAcc";
            goodInfo.strOrderID = "222222222222222";
            goodInfo.bShowAcc = true;
            AddViewItem(goodInfo);

            _GoodsFreshStr goodInfo1 = new _GoodsFreshStr();
            goodInfo1.strAcc = "testAcc111";
            goodInfo1.strOrderID = "BBBBBBBBBBB";
            goodInfo1.bShowAcc = true;
            AddViewItem(goodInfo1);

            goodInfo.strOrderID = "3333333333";
            goodInfo.bShowAcc = false;
            AddViewItem(goodInfo);

            goodInfo.strOrderID = "4444444444";
            goodInfo.bShowAcc = false;
            AddViewItem(goodInfo);

            goodInfo.strOrderID = "4444444444";
            goodInfo.bShowAcc = false;
            goodInfo.bModify = true;
            goodInfo.strFreshStatus = "获取订单成功";
            AddViewItem(goodInfo);

            goodInfo1.strOrderID = "55555555555555";
            goodInfo1.bShowAcc = false;
            AddViewItem(goodInfo1);
            goodInfo1.strOrderID = "6666666666666666";
            goodInfo1.bShowAcc = false;
            AddViewItem(goodInfo1);
            return;
            //%u4E0A%u6D77
            string strProvince = strProvince = Escape("上海");//, Encoding.GetEncoding("gb2312"));
            return;
            //GetImageEx
            GoodsFresh objFreshEx = new GoodsFresh();
            ClassHttpPost webPost = new ClassHttpPost();
            objFreshEx.SetWebPost(webPost);
            string strRet = webPost.GetHttpPage("https://session.trionworlds.com/login?service=unspecified&locale=zh_CN",
                    "gb2312", "get","", "",
                    "",
                    "*/*", "");
            string strError = "";

              //  https://session.trionworlds.com/login;jsessionid=F355EBF3FCC45A052024921548FD6D59
            //<form id="fm1" class="clearfix" action="/login;jsessionid=46E8217B16B969395A786F70C63DB4F0" method="post">
            //
            string strUrl = GetKeyString(strRet, "id=\"fm1\" class=\"clearfix\" action=\"", "\"");
            strUrl = "https://session.trionworlds.com" + strUrl;
            string strCode = GetKeyString(strRet, "name=\"lt\" value=\"", "\""); ;
            string strData = string.Format("[email protected]&password=l19b351k&lt={0}&_eventId=submit",
                    strCode
                );
            strRet = webPost.GetHttpPage(strUrl,
                    "gb2312", "POST","", strData,
                    "https://session.trionworlds.com/login?service=unspecified&locale=zh_CN",
                    "*/*", "");
        }
        private void button1_Click(object sender, EventArgs e)
        {
            ClassHttpPost webpost = new ClassHttpPost();
            string strError = "";
            bool bRet = Login(webpost, "*****@*****.**", "wawawo20", ref strError, false);

            string strUrl = string.Format("http://t.hd.xiaomi.com/index.php?_a={0}&_op=choose", DateTime.Now.ToString("yyyyMMdd"));
            //string strUrlReffer =
            /*
            GoodsFresh fresh = new GoodsFresh();
            fresh.SetWebPost(webpost);
            fresh.AddToCart(textBoxGoodId.Text, textBoxSizeNo.Text, textBoxNum.Text);
            fresh.AddAddress(out strError);
            string strOrderNo = "";
            fresh.SetTransTypeAndPayType(out strOrderNo);
            if (strOrderNo != "")
                MessageBox.Show(strOrderNo);
            */
        }
 public void GetDetailDataEx(string strUrl)
 {
     ShowLogString(strUrl);
     ClassHttpPost webPost = new ClassHttpPost();
     string strRet = webPost.GetHttpPage(strUrl,
         "utf-8", "get", "", "",
         "",
         "*/*", "");
     AnanyzeData(strRet, strUrl);
 }
        public void GetDetailData(string strUrl)
        {
            ShowLogString(strUrl);
            ClassHttpPost webPost = new ClassHttpPost();
            string strRet = webPost.GetHttpPage(strUrl,
                "utf-8", "get", "", "",
                "",
                "*/*", "");
            strRet = strRet.ToLower();
            strRet.Replace("id=asinredirect", "id=\"asinredirect\"");
            if (strRet.IndexOf("id=\"asinredirect\"") < 0)
            {
                AnanyzeData(strRet, strUrl);
                return;
            }

            string strSelect = GetKeyString(strRet, "id=\"asinredirect\"", "</select>");
            while (true)
            {
                int nPos = strSelect.IndexOf("<option");
                if (nPos < 0)
                    break;
                string strId = "";
                if(strSelect.IndexOf("=\"") > 0)
                    strId = GetKeyString(strSelect, "value=\"", "\"");
                else
                    strId = GetKeyString(strSelect, "value", ">");

                if (strId.IndexOf("-") > 0)
                {
                    int iii = 0;
                }

                if (strId != "" && strId.IndexOf("-") < 0)
                {
                    AddToListEx("http://www.amazon.cn/gp/product/" + strId);
                }
                else
                    break;
                nPos = strSelect.IndexOf(">", nPos);
                if (nPos < 0)
                    break;
                strSelect = strSelect.Substring(nPos);
            }
        }
        private bool GetImage(ClassHttpPost m_webPost,string strFile)
        {
            try
            {
                string strUrl = string.Format("http://passport.kedou.com/checkCode.htm?checkCode2=checkCode2&{0}", DateTime.Now.ToString("yyyyMMddHHmmss"));
                Stream stream = m_webPost.GetHttpPageSteam(strUrl, "gb2312", "get", "", "", "http://passport.kedou.com/front/noLogin/goRegist2_front.htm?userType=1&returnCode=quick&site_id=1024_gameclient&return_url=http://www.kedou.com", "*/*", "");
                if (stream == null)
                {
                    return false;
                }

                List<byte> list = new List<byte>();
                while (true)
                {
                    int data = stream.ReadByte();
                    if (data == -1)
                        break;
                    list.Add((byte)data);
                }
                byte[] bytes = list.ToArray();
                if (File.Exists(strFile))
                {
                    File.Delete(strFile);
                }
                FileStream fs = new FileStream(strFile, FileMode.Create);
                BinaryWriter bw = new BinaryWriter(fs);
                bw.Write(bytes);
                bw.Close();
                fs.Close();
                return true;
            }
            catch (System.Exception ex)
            {

            }
            return false;
        }
 private void button4_Click(object sender, EventArgs e)
 {
     ClassHttpPost m_webPost = new ClassHttpPost();
     string strRet = m_webPost.GetHttpPage("http://passport.kedou.com/front/noLogin/goRegist2_front.htm?userType=1&returnCode=quick&site_id=1024_gameclient&return_url=http://www.kedou.com",
             "utf-8", "get", "", "",
             "",
             "*/*", "");
     if (strRet.IndexOf("蝌蚪通行证-注册") < 0)
     {
         MessageBox.Show("load reg page error");
         return;
     }
     string strFile = "c:\\test.bmp";
     bool bRet = GetImage(m_webPost, strFile);
     if (!bRet)
     {
         MessageBox.Show("load image page error");
         return;
     }
     string strCode = GetCode(strFile);
     string strData = string.Format("return_url=http%3A%2F%2Fwww.kedou.com&site_id=1024_gameclient&token=&member.memberPwd=32b60b79d7eae88e0ca4b476ec6f33b4&member.linkEmail=&member.linkMobile=&nextCode=site&returnCode=quick&return_code=&userType=1&regVersion=&regEnvironment=&checkCodeError=&member.memberName=shvsv8918&member.realName=&member.idCardNo=&member.companyName=&member.linkMan=&checkCode={0}", strCode);
     strRet = m_webPost.GetHttpPage("http://passport.kedou.com/front/noLogin/reg.htm",
             "utf-8", "post", "", strData,
             "http://passport.kedou.com/front/noLogin/goRegist2_front.htm?userType=1&returnCode=quick&site_id=1024_gameclient&return_url=http://www.kedou.com",
             "*/*", "");
     int iii = 0;
 }
 //sohu reg
 private void button2_Click(object sender, EventArgs e)
 {
     //GetImageEx
     GoodsFresh objFreshEx = new GoodsFresh();
     ClassHttpPost webPost = new ClassHttpPost();
     objFreshEx.SetWebPost(webPost);
     string strRet = webPost.GetHttpPage("http://passport.sohu.com/web/dispatchAction.action?registerType=Passport&showAllType=1",
             "gb2312", "get","", "",
             "",
             "*/*", "");
     string strError = "";
     objFreshEx.GetImageEx("c:\\ddddddd.bmp", out strError);
     //
     string strCode = "";
     string strNumber = "";
     strCode = "hfabe3a8";
     strNumber = "SCYLSLALELJLAPCLSLELSLAJYJPLYPJPNPULYJPLELYPNJSLJLAJSLYLAPUJUPCLAPLPJPNLYLAJSLYLAPUJUPCLSLAPLPNLALEPJLYLAPCJUPJLYLSLAJYJPLELYPCLEPNJPLEJYLEPNPJPCPJLALSPCPJLALYLEJSPULEJSPNPCPJLAPJLEJUPJLEJSPULEJPJY";
     string strData = string.Format("checkRegType=on&shortname=testregidnew2&user.password=wawawo20&password2=wawawo20&user.question=%CE%D2%BE%CD%B6%C1%B5%C4%D3%D7%B6%F9%D4%B0%C3%FB%B3%C6&questionbak=&answer=%B3%A4%BD%AD%D0%A1%D1%A7&validate={1}&privacy=1&uuidCode={0}&app_para=registerType%3DPassport%26showAllType%3D1&ot_registerid=&registerid=&appid=9998&autologin=1&ru=&domainName=sohu.com&registerType=Passport&showAllType=1",
         strNumber,
         strCode
         );
     strRet = webPost.GetHttpPage("https://passport.sohu.com/web/Passportregister.action",
             "gb2312", "POST","", strData,
             "https://passport.sohu.com/web/dispatchAction.action?registerType=Passport&showAllType=1",
             "*/*", "");
 }
        private void button1_Click(object sender, EventArgs e)
        {
            // _GoodsFreshStr objInfoEx = new _GoodsFreshStr();
            //objInfoEx.strAcc = "aaa";
            TestStr1 bulder = new TestStr1();
            bulder.strAcc = "AAA";
            Hashtable tblHash = new Hashtable();
            bulder.strAcc = "AAABBB";

            _GoodsFreshStr objInfoExEx = new _GoodsFreshStr();

            string strDirectoryXls = System.AppDomain.CurrentDomain.BaseDirectory + "xlsfile";
            SaveToExcel(strDirectoryXls, null, "aaaaa");
            return;
            GoodsFresh objFreshEx = new GoodsFresh();
            ClassHttpPost webPost = new ClassHttpPost();
            objFreshEx.SetWebPost(webPost);

            string strDirect = System.AppDomain.CurrentDomain.BaseDirectory + "pic";
            if (!Directory.Exists(strDirect))
            {
                Directory.CreateDirectory(strDirect);
            }

            return;
            //string str = System.Web.HttpUtility.UrlEncode("你好", Encoding.GetEncoding("gb2312"));
            string str = string.Format("{0}    {1}", 519.0, 535.01);
            MessageBox.Show(str);
            return;
            TimerFunction();
            return;
            string strAcc = "heilongjiangjt";
            _GoodsFreshStr objInfo = new _GoodsFreshStr();
            DataContrl.GetDataCache(strAcc, ref objInfo);
            MessageBox.Show(objInfo.iFreshCount.ToString());
            objInfo.iFreshCount = 2;
            //DataContrl.InitFreshTime();
            DataContrl.GetDataCache(strAcc, ref objInfo);
            MessageBox.Show(objInfo.iFreshCount.ToString());
            return;

            IsSetIllegal(); return;
            _GoodsFreshStr goodInfo = new _GoodsFreshStr();
            bool bRet = DataContrl.GetDataCache("heilongjiangjt", ref goodInfo);
            if (!bRet)
            {
                return;
            }
            GoodsFresh objFresh = new GoodsFresh();
            objFresh.SetWebPost(goodInfo.webPost);
            bRet = objFresh.Login(goodInfo.strAcc, goodInfo.strPwd,true);
            string strError = "";
            objFresh.FreshQuick(out strError,out strError);
        }
        public bool GetPageData(int nPage)
        {
            ClassHttpPost webPost = new ClassHttpPost();
            string strUrl = string.Format("http://www.amazon.cn/gp/feature.html/ref={0}?ie=UTF8&docId={1}&plgroup={2}&plpage={3}",
                                m_strRef, m_strdocId, m_strgpid, nPage);

            if (m_iFreshType == 1)
            {
                if (m_strTempUrl == "")
                    m_strTempUrl = "http://www.amazon.cn/s/ref=sr_nr_p_n_feature_eight_br_mrr_0?rh=n%3A816482051%2Cp_n_feature_eight_browse-bin%3A2051095051%2Cp_n_feature_eight_browse-bin%3A2051096051%2Cp_n_feature_eight_browse-bin%3A2051097051%2Cp_n_feature_eight_browse-bin%3A2051098051&sort=-pct-off&ie=UTF8&page={0}";
                strUrl = string.Format(m_strTempUrl,
                                nPage);
            }
            string strRet = webPost.GetHttpPage(strUrl,
                "utf-8", "get", "", "",
                "",
                "*/*", "");

            strRet = AnanyzePageData(strRet);

            return true;
        }
        //sohu reg
        private void button2_Click(object sender, EventArgs e)
        {
            //GetImageEx
            GoodsFresh objFreshEx = new GoodsFresh();
            ClassHttpPost webPost = new ClassHttpPost();
            objFreshEx.SetWebPost(webPost);
            string strRet = webPost.GetHttpPage("https://session.trionworlds.com/login?service=unspecified&locale=zh_CN",
                    "gb2312", "get","", "",
                    "",
                    "*/*", "");
            string strError = "";

              //  https://session.trionworlds.com/login;jsessionid=F355EBF3FCC45A052024921548FD6D59
            //<form id="fm1" class="clearfix" action="/login;jsessionid=46E8217B16B969395A786F70C63DB4F0" method="post">
            //
            string strUrl = GetKeyString(strRet, "id=\"fm1\" class=\"clearfix\" action=\"", "\"");
            strUrl = "https://session.trionworlds.com" + strUrl;
            string strCode = GetKeyString(strRet, "name=\"lt\" value=\"", "\""); ;
            string strData = string.Format("[email protected]&password=l19b351k&lt={0}&_eventId=submit",
                    strCode
                );
            strRet = webPost.GetHttpPage(strUrl,
                    "gb2312", "POST","", strData,
                    "https://session.trionworlds.com/login?service=unspecified&locale=zh_CN",
                    "*/*", "");
        }
        //sohu reg
        private void button2_Click(object sender, EventArgs e)
        {
            clsMCI cm = new clsMCI();
            cm.FileName = "Notice.mp3";
            cm.play();
            return;
            _GoodsFreshStr goodInfo = null;
            DataContrl.GetDataCache("*****@*****.**", ref goodInfo);
            goodInfo.strFreshStatus = "下单成功";
            ShowStatusInfo(goodInfo);

            DataContrl.GetDataCache("[email protected]", ref goodInfo);
            goodInfo.strFreshStatus = "失败";
            ShowStatusInfo(goodInfo);

            DataContrl.GetDataCache("[email protected]", ref goodInfo);
            goodInfo.strFreshStatus = "登录中...";
            ShowStatusInfo(goodInfo);

            return;
            string strShow = string.Format("{0}", DateTime.Now.ToFileTime());
            MessageBox.Show(strShow);
            return;
            //GetImageEx
            GoodsFresh objFreshEx = new GoodsFresh();
            ClassHttpPost webPost = new ClassHttpPost();
            objFreshEx.SetWebPost(webPost);
            string strRet = webPost.GetHttpPage("https://session.trionworlds.com/login?service=unspecified&locale=zh_CN",
                    "gb2312", "get","", "",
                    "",
                    "*/*", "");
            string strError = "";

              //  https://session.trionworlds.com/login;jsessionid=F355EBF3FCC45A052024921548FD6D59
            //<form id="fm1" class="clearfix" action="/login;jsessionid=46E8217B16B969395A786F70C63DB4F0" method="post">
            //
            string strUrl = GetKeyString(strRet, "id=\"fm1\" class=\"clearfix\" action=\"", "\"");
            strUrl = "https://session.trionworlds.com" + strUrl;
            string strCode = GetKeyString(strRet, "name=\"lt\" value=\"", "\""); ;
            string strData = string.Format("[email protected]&password=l19b351k&lt={0}&_eventId=submit",
                    strCode
                );
            strRet = webPost.GetHttpPage(strUrl,
                    "gb2312", "POST","", strData,
                    "https://session.trionworlds.com/login?service=unspecified&locale=zh_CN",
                    "*/*", "");
        }
 public void SetWebPost(ClassHttpPost webPost)
 {
     m_webPost = webPost;
 }
        public bool Login(ClassHttpPost webPost, string strAcc,string strPwd, ref string strError, bool bForceValidate)
        {
            strError = "";

            string strUrl = "http://t.hd.xiaomi.com/index.php";
            string strRet = webPost.GetHttpPage(strUrl, "utf-8", "get", "", "", "", "*/*", "", null);
               //  strUrl = "http://order.xiaomi.com/site/login?ac=1";
            // strRet = webPost.GetHttpPage(strUrl, "utf-8", "get", "", "", "http://www.xiaomi.com/index.php", "*/*", "", null);
            if (strRet.IndexOf("小米账户") < 0)
            {
                strError = "加载登录页面失败";
                return false;
            }
            string strCheckCode = "";

            string strCallBack = GetKeyString(strRet, "name=\"callback\" value=\"", "\"");
            string strSid = GetKeyString(strRet, "name=\"sid\" value=\"", "\"");
            string strHidden = GetKeyString(strRet, "name=\"hidden\" value=\"", "\"");
            strCallBack = HttpUtility.UrlEncode(strCallBack, Encoding.UTF8);
            strCallBack = strCallBack.Replace("%3a", "%3A");
            strCallBack = strCallBack.Replace("%2f", "%2F");
            strCallBack = strCallBack.Replace("%3f", "%3F");
            strCallBack = strCallBack.Replace("%3d", "%3D");

            string strData = string.Format("passToken=&user={0}&pwd={1}&callback={2}&sid={3}&hidden={4}",
                strAcc,
                strPwd,
                strCallBack,
                strSid,
                strHidden);
            string strReffer = string.Format("https://account.xiaomi.com/pass/serviceLogin?callback={0}&sid={1}&hidden={2}",
                strCallBack,
                strSid,
                strHidden);

            CookieCollection cookies = new CookieCollection();
            cookies.Add(new Cookie("userName", strAcc, "/", "account.xiaomi.com"));
            cookies.Add(new Cookie("uLocale", "zh_CN", "/", "account.xiaomi.com"));
            cookies.Add(new Cookie("uuid", "74842780", "/", "t.hd.xiaomi.com"));
            strUrl = "https://account.xiaomi.com/pass/serviceLoginAuth";
            strRet = webPost.GetHttpPage(strUrl,
                "utf-8", "post", "", strData,
                strReffer,
                "*/*", "", cookies);
            strUrl = "http://t.hd.xiaomi.com/index.php";
            strRet = webPost.GetHttpPage(strUrl, "utf-8", "get", "", "", "http://www.xiaomi.com/index.php", "*/*", "", null);

            //获取页面成功
            return false;
        }