2011-04-07 77 views
3

我正在使用Google的gdata库以编程方式在python中创建日历事件。到目前为止,下面的代码工作正常,除了一两件事:使用gdata python库发送Google日历事件邀请通知

我不能为我的生命得到它发送邀请通知受邀者(或受邀者名单):

import datetime 
import atom 
import gdata.calendar.service 
from gdata.calendar import Who, Where, When 

entry = gdata.calendar.CalendarEventEntry() 
entry.title = atom.Title(text = 'event-title') 
entry.content = atom.Content(text = 'some event etc...') 
entry.send_event_notifications = atom.Entry(text = 'true') #<<<<<<<<<<<<<<<<< 
start = datetime.datetime.now().isoformat() 
entry.when.append(When(start_time=start)) 
entry.where.append(Where(value_string='somewhere')) 
entry.who.append(Who(email = '[email protected]')) 
client = gdata.calendar.service.CalendarService(email='[email protected]', password='pa$$word') 
client.ProgrammaticLogin() 
event = client.InsertEvent(entry,'http://www.google.com/calendar/feeds/default/private/full') 

标记的线是我认为有必要发送邀请通知,但它不起作用。有任何想法吗?

回答

0

您可以使用:

from gdata.calendar import SendEventNotifications 

# [...] stuff 

entry.send_event_notifications = SendEventNotifications(value='true') 
4

其实,正确的语法是:

from gdata.calendar.data import SendEventNotificationsProperty 

# [...] stuff 

entry.send_event_notifications = SendEventNotificationsProperty(value='true') 
相关问题