I developed a module in python which retrieves all calendars list feed
using the method prescribed in google calendar data API.
It was working fine until last week - google server responding with
'200 OK' http response..
But , Since last 2 days google server has been unexpectantly sending
'400 Bad Request' http response on a number of occasions to the same
code to which it was earlier responding with '200 OK' response.
I was wondering whether there is a problem with the google server or
the implementation mechanism has been changed.
Here is the python code :
import httplib
import urllib
import xml.etree.ElementTree
session_id=''
own_calendar_list={} # list of
calendar id
events_list={}
entry_count = 0
events_title={}
def my_authorization():
#emailid = raw_input('enter the email id:')
#passwd = raw_input('enter your password:')
#service = raw_input('enter the service name:')
params = urllib.urlencode({'Email': '[EMAIL PROTECTED]',
'Passwd': 'bad44man', 'service': 'cl'})
auth_headers = {"Content-type": "application/x-www-form-
urlencoded"}
calendar_conn = httplib.HTTPSConnection("www.google.com")
#calendar_conn.set_debuglevel(2)
calendar_conn.request("POST", "/accounts/
ClientLogin",params,auth_headers)
auth_response = calendar_conn.getresponse()
data = auth_response.read()
#print data
token=data.partition('Auth=')
#global auth_token
auth_token = token[2]
print "Auth Token \n"+auth_token
calendar_conn.close()
return auth_token
def get_all_calendar_feed(auth_token,calendar_conn):
header = {"Authorization":"GoogleLogin auth =" + auth_token}
#calendar_conn = httplib.HTTPConnection("www.google.com")
calendar_conn.set_debuglevel(2)
global session_id
if session_id == '':
calendar_conn.request("GET","/calendar/feeds/default/
allcalendars/full",None,header)
response = calendar_conn.getresponse()
data = response.read()
if response.status == 200 :
return data
if response.status == 302 : #
requested object has moved to a new url
list = response.getheaders() # list all the
response headers
i = 0
for list[i] in list :
if str(list[i]).find('location') != -1 :
#print list[i]
moved_uri =
str(list[i]).partition("www.google.com")[2].partition("'")[0]
# extract moved uri from response header
print moved_uri
session_id = moved_uri.partition("=")
[2] # extract session id from
moved uri
print session_id
calendar_conn.request("GET",moved_uri,None,header)
response = calendar_conn.getresponse()
print response.status , response.reason
if response.status == 200 :
all_calendar_feed = response.read()
file = open("all-calendar-feed.xml","w")
file.write(all_calendar_feed)
file.close()
if response.status == 200 :
return all_calendar_feed
else :
return None
if __name__ == "__main__":
auth_token = my_authorization()
calendar_conn = httplib.HTTPConnection("www.google.com")
all = get_all_calendar_feed(auth_token,calendar_conn)
calendar_conn.close()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---