登录谷歌帐户 [英] Login to google account
问题描述
大家好,伙计们,我需要能够登录我的Gmail帐户,然后我会获得cookie并可以访问其他谷歌服务。但我无法登录我的Gmail(或任何goolgle)帐户。我这样做: string formUrl =" https://www.google.com/ accounts / ServiceLoginAuth" ;;     string formParams = string.Format(" Email = {0}& Passwd = {1}& signIn = {2}& PersistentCookie = {3}& GALX = {4}",        "用户名","密码","登录","是"," CfFosrEhu -0");     string cookieHeader;     HttpWebRequest req =(HttpWebRequest)WebRequest.Create(formUrl);     req.ContentType =" application / x-www-form-urlencoded";     req.Referer =" https://www.google.com/accounts/ServiceLoginAuth" ;;     req.Method =" POST";     req.UserAgent =" Mozilla / 5.0(Windows; U; Windows NT 5.1; ru; rv:1.9.2.7)Gecko / 20100713 Firefox / 3.6.7";        req.AllowAutoRedirect = false;     req.CookieContainer = new CookieContainer();     req.Headers.Add(HttpRequestHeader.CacheControl," no-cache = set-cookie");
< p style =""> &NBSP; &NBSP; byte [] bytes = Encoding.ASCII.GetBytes(formParams);
&NBSP; &NBSP; req.ContentLength = bytes.Length;
&NBSP; &NBSP; using(Stream os = req.GetRequestStream())
&NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; os.Write(bytes,0,bytes.Length);
&NBSP; &NBSP; }
&NBSP; &NBSP; WebResponse resp = req.GetResponse();
&NBSP; &NBSP; using(StreamReader sr = new StreamReader(resp.GetResponseStream()))
&NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; string s = sr.ReadToEnd();
&NBSP; &NBSP; }
那么问题是什么?你说过你想做什么,但不知道出了什么问题。
Hi, folks, I need to be able to login to my gmail account, then i get cookies and will have access to other google services. But i can't login to my gmail(or any goolgle) account. I do : string formUrl = "https://www.google.com/accounts/ServiceLoginAuth"; string formParams = string.Format("Email={0}&Passwd={1}&signIn={2}&PersistentCookie={3}&GALX={4}", "username", "password", "Sign in", "yes", "CfFosrEhu-0"); string cookieHeader; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(formUrl); req.ContentType = "application/x-www-form-urlencoded"; req.Referer = "https://www.google.com/accounts/ServiceLoginAuth"; req.Method = "POST"; req.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.2.7) Gecko/20100713 Firefox/3.6.7"; req.AllowAutoRedirect = false; req.CookieContainer = new CookieContainer(); req.Headers.Add(HttpRequestHeader.CacheControl, "no-cache=set-cookie"); byte[] bytes = Encoding.ASCII.GetBytes(formParams); req.ContentLength = bytes.Length; using (Stream os = req.GetRequestStream()) { os.Write(bytes, 0, bytes.Length); } WebResponse resp = req.GetResponse(); using (StreamReader sr = new StreamReader(resp.GetResponseStream())) { string s = sr.ReadToEnd(); }
So what's the problem? You've said what you want to do but not what's going wrong.
这篇关于登录谷歌帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!