其他分享
首页 > 其他分享> > 联通营业厅API 获取个人信息

联通营业厅API 获取个人信息

作者:互联网

联通营业厅API 获取个人信息

  复制代码
                string newValue = base.Request["tel"];
                string newValue2 = base.Request["pwd"];
                string postUrl = "https://uac.10010.com/portal/Service/MallLogin";
                string text = "callback=jQuery17204603273952720519_1482133308884&req_time=1482133346899&redirectURL=http%3A%2F%2Fwww.10010.com&userName=@tel&password=@pwd&pwdType=01&productType=01&redirectType=03&
rememberMe=1&_=1482133346900"; text = text.Replace("@tel", newValue).Replace("@pwd", newValue2); CookieContainer cookie = WebClientHelper.GetCookie(text, postUrl); string content = WebClientHelper.GetContent(cookie, "https://uac.10010.com/cust/infomgr/anonymousInfoAJAX"); base.Response.Write(content);

复制代码 复制代码



public static class WebClientHelper { public static CookieContainer GetCookie(string postString, string postUrl) { CookieContainer cookieContainer = new CookieContainer(); HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(postUrl); httpWebRequest.CookieContainer = cookieContainer; httpWebRequest.Method = "POST"; httpWebRequest.KeepAlive = true; httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko"; httpWebRequest.Accept = "text/html, application/xhtml+xml, */*"; httpWebRequest.ContentType = "application/x-www-form-urlencoded"; byte[] bytes = Encoding.UTF8.GetBytes(postString); httpWebRequest.ContentLength = (long)bytes.Length; Stream requestStream = httpWebRequest.GetRequestStream(); requestStream.Write(bytes, 0, bytes.Length); requestStream.Close(); HttpWebResponse arg_85_0 = (HttpWebResponse)httpWebRequest.GetResponse(); return cookieContainer; } public static string GetContent(CookieContainer cookie, string url) { HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.CookieContainer = cookie; httpWebRequest.Referer = url; httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko"; httpWebRequest.Accept = "text/html, application/xhtml+xml, */*"; httpWebRequest.ContentType = "application/x-www-form-urlencoded"; httpWebRequest.Method = "GET"; HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); string result; using (Stream responseStream = httpWebResponse.GetResponseStream()) { using (StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8)) { result = streamReader.ReadToEnd(); } } return result; } }
复制代码

 

标签:string,CookieContainer,text,HttpWebRequest,个人信息,API,postUrl,httpWebRequest,营业厅
来源: https://www.cnblogs.com/sexintercourse/p/16344165.html