Example #1
0
        /// <summary>
        /// 充值
        /// </summary>
        /// <param name="ppcm"></param>
        /// <param name="captchaVal"></param>
        /// <returns></returns>
        public async Task<PostPayCardBak> PostPayCard(PostPayCardModel ppcm, string captchaVal)
        {
            if (string.IsNullOrWhiteSpace(captchaVal) || ppcm == null)
                return null;
            string _url = "http://shop.10086.cn/i/v1/pay/card/" + ppcm.chargedNum +
                "?captchaVal=" + captchaVal;

            try
            {
                ppcm.longliveLolita = PostPayCardnMisKey();
                ppcm.cardPwd = PostPayCardnEcrypt(ppcm.cardPwd, ppcm.longliveLolita);

                string postDataStr = JsonConvert.SerializeObject(ppcm); 

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_url);
                request.Method = "POST";
                request.KeepAlive = true;
                request.Host = "shop.10086.cn";
                request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0";
                request.ContentType = "application/json";
                request.Accept = "application/json, text/javascript, */*; q=0.01";
                request.Headers["Origin"] = "http://shop.10086.cn";
                request.Headers["X-Requested-With"] = "XMLHttpRequest";
                request.Referer = "http://shop.10086.cn/i/?f=rechargecredit";
                request.Headers["Accept-Encoding"] = "gzip,deflate";
                request.Headers["Accept-Language"] = "zh-CN,zh;q=0.8";

                if (cookie != null)
                    request.CookieContainer = cookie;
                else
                    request.CookieContainer = new CookieContainer();

                Encoding encoding = Encoding.UTF8;//根据网站的编码自定义  

                byte[] postData = encoding.GetBytes(postDataStr);//postDataStr即为发送的数据,格式还是和上次说的一样  
                request.ContentLength = postData.Length;
                Stream requestStream = request.GetRequestStream();
                requestStream.Write(postData, 0, postData.Length); 

                using (HttpWebResponse mResponse = (HttpWebResponse)request.GetResponse())
                {
                    cookie = request.CookieContainer;//如果用不到Cookie,删去即可  
                    using (Stream mStream = mResponse.GetResponseStream())
                    {
                        using (StreamReader myStreamReader =
                            new StreamReader(mStream, Encoding.GetEncoding("utf-8")))
                        {
                            string retString = await myStreamReader.ReadToEndAsync();
                            return JsonConvert.DeserializeObject<PostPayCardBak>(retString);
                        }
                    }
                }
            }
            catch (Exception)
            {

            }

            return null;
        }
Example #2
0
        /// <summary>
        /// 充值
        /// </summary>
        /// <param name="ppcm"></param>
        /// <param name="captchaVal"></param>
        /// <returns></returns>
        public async Task <PostPayCardBak> PostPayCard(PostPayCardModel ppcm, string captchaVal)
        {
            if (string.IsNullOrWhiteSpace(captchaVal) || ppcm == null)
            {
                return(null);
            }
            string _url = "http://shop.10086.cn/i/v1/pay/card/" + ppcm.chargedNum +
                          "?captchaVal=" + captchaVal;

            try
            {
                ppcm.longliveLolita = PostPayCardnMisKey();
                ppcm.cardPwd        = PostPayCardnEcrypt(ppcm.cardPwd, ppcm.longliveLolita);

                string postDataStr = JsonConvert.SerializeObject(ppcm);

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_url);
                request.Method                      = "POST";
                request.KeepAlive                   = true;
                request.Host                        = "shop.10086.cn";
                request.UserAgent                   = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0";
                request.ContentType                 = "application/json";
                request.Accept                      = "application/json, text/javascript, */*; q=0.01";
                request.Headers["Origin"]           = "http://shop.10086.cn";
                request.Headers["X-Requested-With"] = "XMLHttpRequest";
                request.Referer                     = "http://shop.10086.cn/i/?f=rechargecredit";
                request.Headers["Accept-Encoding"]  = "gzip,deflate";
                request.Headers["Accept-Language"]  = "zh-CN,zh;q=0.8";

                if (cookie != null)
                {
                    request.CookieContainer = cookie;
                }
                else
                {
                    request.CookieContainer = new CookieContainer();
                }

                Encoding encoding = Encoding.UTF8;                //根据网站的编码自定义

                byte[] postData = encoding.GetBytes(postDataStr); //postDataStr即为发送的数据,格式还是和上次说的一样
                request.ContentLength = postData.Length;
                Stream requestStream = request.GetRequestStream();
                requestStream.Write(postData, 0, postData.Length);

                using (HttpWebResponse mResponse = (HttpWebResponse)request.GetResponse())
                {
                    cookie = request.CookieContainer;//如果用不到Cookie,删去即可
                    using (Stream mStream = mResponse.GetResponseStream())
                    {
                        using (StreamReader myStreamReader =
                                   new StreamReader(mStream, Encoding.GetEncoding("utf-8")))
                        {
                            string retString = await myStreamReader.ReadToEndAsync();

                            return(JsonConvert.DeserializeObject <PostPayCardBak>(retString));
                        }
                    }
                }
            }
            catch (Exception)
            {
            }

            return(null);
        }
Example #3
0
        public PhoneSearchGetBak PostPayCard(PostPayCardModel ppcm, string captchaVal)
        {
            if (string.IsNullOrWhiteSpace(captchaVal) || ppcm == null)
            {
                return(null);
            }
            string _url = "http://shop.10086.cn/i/v1/pay/card/" + ppcm.chargedNum +
                          "?captchaVal=" + captchaVal;
            HttpResponseMessage response = null;

            try
            {
                //this.cookiestr = "jsessionid-echd-cpt-cmcc-jt=" + jsessionid + ";";

                _httpClient = new HttpClient(handler);
                _httpClient.DefaultRequestHeaders.Add(HOST_H, "shop.10086.cn");
                _httpClient.DefaultRequestHeaders.Add(CONNECTION_H, "keep-alive");
                _httpClient.DefaultRequestHeaders.Add(ACCEPT_H, "application/json, text/javascript, */*; q=0.01");
                _httpClient.DefaultRequestHeaders.Add("Origin", "http://shop.10086.cn");
                _httpClient.DefaultRequestHeaders.Add(XMLHTTP_REQUEST_H, XMLHTTP_REQUEST);
                _httpClient.DefaultRequestHeaders.Add(USER_AGENT_H, "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0");
                _httpClient.DefaultRequestHeaders.TryAddWithoutValidation(CONTENT_TYPE_H, "application/json");
                _httpClient.DefaultRequestHeaders.Add(REFERER_H, "http://shop.10086.cn/i/?f=rechargecard");
                _httpClient.DefaultRequestHeaders.Add(ACCEPT_ENCODEING_H, "gzip,deflate");
                _httpClient.DefaultRequestHeaders.Add(ACCEPT_LANGUAGE_H, "zh-CN,zh;q=0.8");

                var longliveLolita = PostPayCardnMisKey();

                ////使用FormUrlEncodedContent做HttpContent
                //var content = new FormUrlEncodedContent(new Dictionary<string, string>()
                //{    {"cardPwd",PostPayCardnEcrypt(ppcm.cardPwd,longliveLolita)},
                //     {"chargedNum", ppcm.chargedNum},
                //     {"longliveLolita", longliveLolita}
                // });

                List <KeyValuePair <String, String> > paramList = new List <KeyValuePair <String, String> >();
                paramList.Add(new KeyValuePair <string, string>("cardPwd",
                                                                PostPayCardnEcrypt(ppcm.cardPwd, longliveLolita)));
                paramList.Add(new KeyValuePair <string, string>("chargedNum", ppcm.chargedNum));
                paramList.Add(new KeyValuePair <string, string>("longliveLolita", longliveLolita));
                var content = new FormUrlEncodedContent(paramList);

                response = _httpClient.PostAsync(_url, content).Result;
                if (response.StatusCode == HttpStatusCode.OK)
                {   //已经连接,正在接收数据
                    string result = response.Content.ReadAsStringAsync().Result;

                    return(JsonConvert.DeserializeObject <PhoneSearchGetBak>(result));
                }
                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
            finally
            {
                if (response != null)
                {
                    response.Dispose();
                }
            }
        }
Example #4
0
        public PhoneSearchGetBak PostPayCard(PostPayCardModel ppcm, string captchaVal)
        {
            if (string.IsNullOrWhiteSpace(captchaVal) || ppcm == null)
                return null;
            string _url = "http://shop.10086.cn/i/v1/pay/card/" + ppcm.chargedNum +
                "?captchaVal=" + captchaVal;
            HttpResponseMessage response = null;
            try
            {
                //this.cookiestr = "jsessionid-echd-cpt-cmcc-jt=" + jsessionid + ";";

                _httpClient = new HttpClient(handler);
                _httpClient.DefaultRequestHeaders.Add(HOST_H, "shop.10086.cn");
                _httpClient.DefaultRequestHeaders.Add(CONNECTION_H, "keep-alive");
                _httpClient.DefaultRequestHeaders.Add(ACCEPT_H, "application/json, text/javascript, */*; q=0.01");
                _httpClient.DefaultRequestHeaders.Add("Origin", "http://shop.10086.cn");
                _httpClient.DefaultRequestHeaders.Add(XMLHTTP_REQUEST_H, XMLHTTP_REQUEST);
                _httpClient.DefaultRequestHeaders.Add(USER_AGENT_H, "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0");
                _httpClient.DefaultRequestHeaders.TryAddWithoutValidation(CONTENT_TYPE_H, "application/json");
                _httpClient.DefaultRequestHeaders.Add(REFERER_H, "http://shop.10086.cn/i/?f=rechargecard");
                _httpClient.DefaultRequestHeaders.Add(ACCEPT_ENCODEING_H, "gzip,deflate");
                _httpClient.DefaultRequestHeaders.Add(ACCEPT_LANGUAGE_H, "zh-CN,zh;q=0.8");

                var longliveLolita = PostPayCardnMisKey();

                ////使用FormUrlEncodedContent做HttpContent
                //var content = new FormUrlEncodedContent(new Dictionary<string, string>()       
                //{    {"cardPwd",PostPayCardnEcrypt(ppcm.cardPwd,longliveLolita)},
                //     {"chargedNum", ppcm.chargedNum},
                //     {"longliveLolita", longliveLolita}
                // });

                List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>();
                paramList.Add(new KeyValuePair<string, string>("cardPwd", 
                    PostPayCardnEcrypt(ppcm.cardPwd, longliveLolita)));
                paramList.Add(new KeyValuePair<string, string>("chargedNum", ppcm.chargedNum));
                paramList.Add(new KeyValuePair<string, string>("longliveLolita", longliveLolita));
                var content = new FormUrlEncodedContent(paramList);

                response = _httpClient.PostAsync(_url, content).Result;
                if (response.StatusCode == HttpStatusCode.OK)
                {   //已经连接,正在接收数据

                    string result = response.Content.ReadAsStringAsync().Result;

                    return JsonConvert.DeserializeObject<PhoneSearchGetBak>(result);
                }
                return null;
            }
            catch (Exception)
            {
                return null;
            }
            finally
            {
                if (response != null)
                    response.Dispose();
            }
        }