Beispiel #1
0
        string answer = "";                     //验证码答案

        public FrmLogin()
        {
            InitializeComponent();

            //加载广告
            this.Hide();
            FrmAdver adver = new FrmAdver();

            adver.Show();


            //动态加载查票url
            using (StreamReader sr = new StreamReader(_requestHelper.GetStream("get", Api12306.init, "")))
            {
                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.IndexOf("ctx") > -1)
                    {
                        Api12306.ctx = line.Split('=')[1].Replace(" ", "").Replace(";", "").Replace("'", "");
                    }

                    if (line.IndexOf("CLeftTicketUrl ") > -1)
                    {
                        Api12306.queryTicketUrl = line.Split('=')[1].Replace(" ", "").Replace(";", "").Replace("'", "");
                    }
                    if (line.IndexOf("passport_login ") > -1)
                    {
                        Api12306.passport_login = line.Split('=')[1].Replace(" ", "").Replace(";", "").Replace("'", "");
                    }
                    if (line.IndexOf("passport_captcha ") > -1)
                    {
                        Api12306.passport_captcha = line.Split('=')[1].Replace(" ", "").Replace(";", "").Replace("'", "");
                    }

                    if (line.IndexOf("passport_authuam ") > -1)
                    {
                        Api12306.passport_authuam = line.Split('=')[1].Replace(" ", "").Replace(";", "").Replace("'", "");
                    }
                    if (line.IndexOf("passport_captcha_check ") > -1)
                    {
                        Api12306.passport_captcha_check = line.Split('=')[1].Replace(" ", "").Replace(";", "").Replace("'", "");
                    }
                    if (line.IndexOf("passport_authclient ") > -1)
                    {
                        Api12306.passport_authclient = line.Split('=')[1].Replace(" ", "").Replace(";", "").Replace("'", "");
                    }

                    line = sr.ReadLine();
                }
            }

            adver.Close();
            this.Show();


            GetValidateCode();
        }
Beispiel #2
0
        string answer = "";                     //验证码答案

        public FrmLogin()
        {
            InitializeComponent();

            //加载广告
            this.Hide();
            FrmAdver adver = new FrmAdver();

            adver.Show();

            //加载设备id
            string json = _requestHelper.GetData("get", Api12306.logDeviceUrl + Common.GetTimeSpan(DateTime.Now));

            if (json != null)
            {
                json = json.Replace("callbackFunction('", "").Replace("')", "");
                if (Common.IsJson(json))
                {
                    // 添加设备cookie
                    var obj = JObject.Parse(json);
                    _requestHelper.AddCookie("RAIL_EXPIRATION", obj["exp"].ToString());
                    _requestHelper.AddCookie("RAIL_DEVICEID", obj["dfp"].ToString());
                }
                else
                {
                    MessageBox.Show("获取设备信息失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("获取设备信息失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }



            //动态加载查票url
            using (StreamReader sr = new StreamReader(_requestHelper.GetStream("get", Api12306.init, "")))
            {
                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.IndexOf("ctx") > -1)
                    {
                        Api12306.ctx = line.Split('=')[1].Replace(" ", "").Replace(";", "").Replace("'", "");
                    }

                    if (line.IndexOf("CLeftTicketUrl ") > -1)
                    {
                        Api12306.queryTicketUrl = line.Split('=')[1].Replace(" ", "").Replace(";", "").Replace("'", "");
                    }
                    if (line.IndexOf("passport_login ") > -1)
                    {
                        Api12306.passport_login = line.Split('=')[1].Replace(" ", "").Replace(";", "").Replace("'", "");
                    }
                    if (line.IndexOf("passport_captcha ") > -1)
                    {
                        Api12306.passport_captcha = line.Split('=')[1].Replace(" ", "").Replace(";", "").Replace("'", "");
                    }

                    if (line.IndexOf("passport_authuam ") > -1)
                    {
                        Api12306.passport_authuam = line.Split('=')[1].Replace(" ", "").Replace(";", "").Replace("'", "");
                    }
                    if (line.IndexOf("passport_captcha_check ") > -1)
                    {
                        Api12306.passport_captcha_check = line.Split('=')[1].Replace(" ", "").Replace(";", "").Replace("'", "");
                    }
                    if (line.IndexOf("passport_authclient ") > -1)
                    {
                        Api12306.passport_authclient = line.Split('=')[1].Replace(" ", "").Replace(";", "").Replace("'", "");
                    }

                    line = sr.ReadLine();
                }
            }

            adver.Close();
            this.Show();


            GetValidateCode();
        }