2010-01-10 53 views
0

我从来没有尝试过,但现在我真的需要通过Sprint网站(www.sprint.com)的授权。HttpWebRequest SSL授权表

你们能帮我理解这个实际上是如何工作的吗?

我想要这样做,但显然我失去了一些东西。要么是关于饼干 或ssl或其他的东西,我不知道。

HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(
               "https://sso.sprintpcs.com/sso/Login.do"); 
    CookieContainer cookieContainer = new CookieContainer(); 
    webRequest.CookieContainer = cookieContainer; 
    webRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; 
          chromeframe; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; 
          .NET CLR 3.0.30729; Tablet PC 2.0; .NET4.0C; .NET4.0E)"; 
    webRequest.Accept = "image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, 
         image/pjpeg, application/x-ms-xbap, application/x-shockwave-flash, 
         application/vnd.ms-excel, application/msword, */*"; 

    webRequest.Method = "POST"; 
    webRequest.Host = "manage.sprintpcs.com"; 

    string strUserId = "kindauser"; 
    string strPass = "kindapass"; 

    ASCIIEncoding encoding = new ASCIIEncoding(); 
    string postData = "userid=" + strUserId + "&password=" 
        + strPass + "&userExperince=USC allowlogin=false"; 

    byte[] data = encoding.GetBytes(postData); 
    Stream requestStream = webRequest.GetRequestStream(); 
    requestStream.Write(data,0,data.Length); 

    HttpWebResponse myHttpWebResponse = (HttpWebResponse)webRequest.GetResponse(); 
+1

userExperince看起来像一个错字 – SpliFF 2010-01-10 01:44:59

回答

1

我会做以下 - 这适用于所有您想与网站互动的情况。

1)得到firefox,随着萤火虫扩展。 2)清除火狐内容和cookie缓存 3)使用firefox做场景 - 登录到网站,例如。 4)在这一点上,萤火虫显示与cookie头等一起发送请求的确切顺序。

5)现在尝试使用代码复制此。