2010-01-10 56 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)現在嘗試使用代碼複製此。