tags:

views:

364

answers:

3

I presume the following are the steps I should do:

A) I need to post the following for login:

POST /accounts/ClientLogin HTTP/1.0 Content-type: application/x-www-form-urlencoded

accountType=HOSTED_OR_GOOGLE&[email protected]&Passwd=north23AZ&service=cl& source=Gulp-CalGulp-1.05

B) Need to check the return code

C) If it returns a success code I need to download the spreadsheet in the following sample url: http://spreadsheets.google.com/fm?key=DOCUMENT_ID&fmcmd=4&hl=en

How can I do the above operations in C#?

EDITED: I have done until logging in. The response stream is something like this. I'm not sure how to download the excel sheet using this. Any hint would be of great help.

The response stream is as follows:

SID=DQAAAIcAAADFWSVJV-6__fb211rhQLHU_jCQ1sKElh-qOf7V10WI1PUQsKmuTdPD2DEWGdbspK2h7DFxH7DPwDIQaTt1RGhwxSq9isqkmlFgcyX8nu7EotpwOfAnyGrD9mL4N vOVq4MM0FfRWVNlOn64wNM3W4tN0DTN5mLx1_jYHVD5png7esvwneScOSf6wEXGoQfsw5E LSID=DQAAAIkAAACzE9S9RdLtuCl6gfbWn9CKn4nhCdAmW4d0yLp4ypT2In769POcAsQBKiQ-VLH1Y194EuqIVrYoQTphK0Na2GQf_DWwHmXSyToZoqIh2c5GVXA0k_0IH8j745GjzLEqLpVmH2oJFNxOJYpu02If 5O8Wd1x99AsxJ35rz1OHDq_XlDBW4192pReV7SQxSf7z4-4 Auth=DQAAAIkAAACz5fRdLtuCl6gfbWn9CKn4nhCdAmW4d0yLp4ypT2In769POcAsQBKiQ-VLH1Y1-g-zsSlAXwWMwUNufqHku2F5LoAxLIElcF4aLcnQYVGs7xKNX9XlCgwubHkw7sYm4aEnjpLp0Fpmyb_paP_BABWQ ahpM5oyWob5f4KfoLFC7ltcFAVjgJjXsAAjHkToUg

EDIT: This is the request header captured by FireBug: (I don't understand some of these parameters to create a HTTP request in C#) Pls help.

Host

spreadsheets.google.com

User-Agent

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)

Accept

text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8

Accept-Language

en-us,en;q=0.5

Accept-Encoding

gzip,deflate

Accept-Charset

ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive

300

Proxy-Connection

keep-alive

Cookie

PREF=ID=090597c918ef0061:TM=1245011295:LM=1245011295:S=qs8OO7D02yy9tKj8; rememberme=false; SID=DQAAA IUAAAAi0iAuzneHzKleShR4itA8-zGxSKw6hqf8qBHBHJBLbNpynNOon7Ni96C4ckRcVVC5Wt89K8PywrKK5qjTmscrqizfWHygV _nPssvw5uOL9IcEWpa5aqUfeQyk-vsEMHYjLe9Ko0i2pAJrQxBrNFii588ucAVtyNoSrZVzAtZADXhhywHUK8x-LezoUaHiEbM

A: 

It looks like that SID is the 'session id', which presumably is a cookie that you should send back in your next POST/GET.

Chris
+1  A: 

Another thing to look at is Fiddler:

http://www.fiddler2.com/fiddler2/

Use it to get an idea of the interactions between your browser and google when you download your spreadsheet 'normally', and then code your application to mimic it.

Chris
A: 

Its not very difficult: download the Google SS API, and look at the sample code - it will connect you to your Google docs, and you can easily pass the data to Excel if you built it as a VSTO Addin in Visual Studio - did it myself in a day, but would not be inclined to post the code with 'no legwork' done first.

James