开发者

Gmail's Last activity

开发者 https://www.devze.com 2023-03-03 02:16 出处:网络
How can I get data from gmail\'s last account activity page: img This information is available under address: https://mail.google.com/mail/?ui=2&ik=SOME_ACCOUNT_ID&view=ac

How can I get data from gmail's last account activity page:

img

Gmail's Last activity

This information is available under address: https://mail.google.com/mail/?ui=2&ik=SOME_ACCOUNT_ID&view=ac

The problem is I don't know how to authenti开发者_运维百科cate to access this page. I suppose I should use OAuth protocol somehow, but don't know details.

I would like to use C#

Does anyone have some tips ?


Take a look at the following page:

http://code.google.com/googleapps/domain/email_settings/developers_guide_protocol.html#GA_email_settings_api_auth

You basically have to obtain an Authentication Token by Posting to this URL:

https://www.google.com/accounts/ClientLogin

The posting data format has to be as follows:

&Email=<email_address>&Passwd=<password>&accountType=HOSTED&service=apps

Pete


The https://mail.google.com/mail/?ui=2&ik=SOME_ACCOUNT_ID&view=ac do not work now? I get some javascript code. My code:

 string URL1 = "https://mail.google.com/mail/";
        string clientID = "my_client_id";
        string httpBody1 =
            string.Format(
                "ui=2&ik={0}&view=ac",
                clientID);
        var request1 = WebRequest.Create(URL1) as HttpWebRequest;
        request1.ContentType = "application/x-www-form-urlencoded";
        request1.Method = "POST";
        using (var streamWriter1 = new StreamWriter(request1.GetRequestStream()))
        {
            streamWriter1.Write(httpBody);
        }

        using (HttpWebResponse httpWebResponse1 = request1.GetResponse() as HttpWebResponse)
        {
            if (httpWebResponse1.StatusCode == HttpStatusCode.OK)
            {
                using (Stream stream1 = httpWebResponse1.GetResponseStream())
                {
                    StreamReader readStream1 = new StreamReader(stream1, Encoding.UTF8);
                    Console.Out.WriteLine(readStream1.ReadToEnd());
                }
            }
        }
0

精彩评论

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