我正在使用Google的gdata库以编程方式在python中创建日历事件。到目前为止,以下代码工作正常,除了一件事:
我不能为我的生活让它向被邀请者(或受邀者名单)发送邀请通知:
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 = 'invitee@gmail.com'))
client = gdata.calendar.service.CalendarService(email='inviter@gmail.com', password='pa$$word')
client.ProgrammaticLogin()
event = client.InsertEvent(entry,'http://www.google.com/calendar/feeds/default/private/full')
标记的行是我认为发送邀请通知所必需的,但它不起作用。有什么想法吗?
答案 0 :(得分:4)
实际上,正确的语法是:
from gdata.calendar.data import SendEventNotificationsProperty
# [...] stuff
entry.send_event_notifications = SendEventNotificationsProperty(value='true')
答案 1 :(得分:0)
您可以使用:
from gdata.calendar import SendEventNotifications
# [...] stuff
entry.send_event_notifications = SendEventNotifications(value='true')