2011-01-26 20 views
2

我想知道是否可以在辅助日历中使用Google API创建和删除事件。我很清楚如何在主日历中这样做,所以我只问,如何更改calendar_service来读取和写入其他日历。
我试过使用辅助日历电子邮件登录,但这不可能与BadAuthentication Error。该URL肯定是正确的,因为它是通过API读取的。
等待你的帮助。如何使用Google Python API编辑辅助日历

回答

1

A'm回答我自己的问题,所以我终于可以接受这一个。这个问题已经在一段时间之前解决了。

最重要的答案是在这documentation

每个查询都可以使用uri作为参数运行。例如“InsertEvent(event,uri)”。 Uri可以手动设置(从谷歌日历设置)或自动设置,如下面的帖子所写。请注意,CalendarEventQuery只接受用户名,而不是整个网址。

两个建设云这样说:

用户= “[email protected]

URI =“http://www.google.com/calendar/feeds/ {{user}}/private/full-noattendees“

有用的是,您可以使用不同的uri运行查询并在一个脚本中将许多不同的日历添加/删除事件。

希望有人认为它有帮助。

0

我得到了同样的问题,但我发现这个解决方案(我不记得在哪里)

该解决方案是由谷歌

提供其src网址提取辅助日历的用户这可能不是更好的一个,但它是一个工作的

注:代码是从一个真实的项目中提取的[某些部分已被删除],必须适应您的具体情况,并提供样本只是为了解释支持将不起作用)

# 1 - Connect using the main user email address in a classical way 

cal_client = gdata.calendar.service.CalendarService() 
# insert here after connection stuff 

# 2 - For each existing calendars 

feed = cal_client.GetAllCalendarsFeed(): 

# a loop the find the calendar by it's title (cal_title) 
for a_calendar in feed.entry: 
    if cal_title in a_calendar.title.text: 
     cal_user = a_calendar.content.src.split('/')[5].replace('%40','@') 
     # If you print a_calendar.content.src.split you will see that the url 
     # contains an email like definition. This is the one to used to work 
     # with the calendar 

然后,您只需将cal中的默认用户替换为api中的cal_user即可在辅助日历上工作。

更换调用是必需的,因为谷歌的API函数正在做的特殊字符,如“%”

内部转换我希望这会帮助你。

+0

我发现了另一种方式,类似于你的,但更有弹性。通过弹性我的意思是你可以添加事件到你想要的任何共享日历。我在第一篇文章中写过它。 – Gandi 2011-02-09 11:17:57

相关问题