我可以批量向Google日历添加多个事件,但这仅限于我的默认日历。我如何能够使用相同的代码来处理我拥有URL的另一个日历?
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
另请注意,我已经能够使用该URL自行添加事件。
答案 0 :(得分:1)
看code,似乎:
DEFAULT_BATCH_URL = 'http://www.google.com/calendar/feeds/default/private/full/batch'
在您的代码中,看起来它正在尝试解析部分网址。如果您将URL格式化为:
url = 'http://www.google.com/calendar/feeds/.../private/full/batch'
它应该有用。