开发者

Windows Live ID login via HttpRequest

I want interact with one web via HttpRequest/HttpResponse. But the web requires login via Windows Live ID. I go to the live login page, but I can'开发者_如何学Pythont get any usable response from login page.

The code used to access the login page:

var request = (HttpWebRequest)WebRequest.Create("http://login.live.com/");
request.Timeout = 30000; 
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8 (.NET CLR 3.5.30729)"; 
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; 
request.Headers.Add("Accept-Language", "en-us,en;q=0.5"); 
request.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); 
request.Headers.Add("Keep-Alive", "300"); 
request.ContentType = "application/x-www-form-urlencoded"; 
request.CookieContainer = new CookieContainer(); 
request.Method = WebRequestMethods.Http.Get; 

var response = (HttpWebResponse)request.GetResponse();

And the response:

Cookies must be allowed

Your browser is currently set to block cookies. Your browser must allow cookies before you can use Windows Live ID.

Cookies are small text files stored on your computer that tell Windows Live ID sites and services when you're signed in. To learn how to allow cookies, see online help in your web browser.

I have no problem with cookies on another web pages and I can't found any way, how to get over this message.

Do you anybody have an idea, how to solve it? Thanks!


Try to set the capacity property for CookieContainer object.

....
request.CookieContainer = new CookieContainer(1000); 


I found a complete tutorial on how to access Windows Live ID with C# and building the client.

Read here: http://www.devarticles.com/c/a/C-Sharp/Hotmail-Exposed-Access-Hotmail-using-C-sharp/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜