联通营业厅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; } }
原文地址:https://www.cnblogs.com/myshowtime/p/6282451.html