2012-08-15 127 views
0

我可以批量向Google日历添加多个活动,但这仅限于我的默认日历。我将如何获得相同的代码来处理另一个具有URL的日历?Python Google日历API问题

request_feed = gdata.calendar.CalendarEventFeed() 

# add events to the request_feed 
request_feed.AddInsert(entry=InsertSingleEvent(calendar_service, "walk the dog at 4:00pm")) 
request_feed.AddInsert(entry=InsertSingleEvent(calendar_service, "walk the cat at 5:00pm")) 

response_feed = calendar_service.ExecuteBatch(request_feed, 
gdata.calendar.service.DEFAULT_BATCH_URL)) 

这会正常工作,所有事件都会在我的日历中显示。但是,当我更换:

response_feed = calendar_service.ExecuteBatch(request_feed, 
gdata.calendar.service.DEFAULT_BATCH_URL)) 

有了:

url = 'calendar/feeds/.../private/full' 
response_feed = calendar_service.ExecuteBatch(request_feed, 
url)) 

我得到的错误:

gaierror: [Errno 11004] getaddrinfo failed 

同时请注意,我已经能够使用该网址自行添加事件。

回答

1

望着code,似乎:

DEFAULT_BATCH_URL = 'http://www.google.com/calendar/feeds/default/private/full/batch' 

在你的代码,它看起来像它试图解决部分URL。如果将URL格式化为:

url = 'http://www.google.com/calendar/feeds/.../private/full/batch' 

它应该工作。

+0

这几乎是完整的解决方案。我还必须在url的末尾添加/批处理 – bs7280 2012-08-16 00:42:42

+0

呃,呃 - 我会追加解决方案以备将来参考。很高兴它的工作。 – RocketDonkey 2012-08-16 00:54:31