2011-03-16 73 views
2

我有以下代码来创建一个Gmail联系人的新日历:有没有更改Google日历的访问级别的方法?

// Create a CalenderService and authenticate 
CalendarService myService = new CalendarService("exampleCo-exampleApp-1"); 
myService.setUserCredentials("[email protected]", "password"); 

CalendarEntry calendar = new CalendarEntry 
{ 
    Title = { Text = "Example title" }, 
    Summary = { Text = "Example summary" }, 
    TimeZone = "Europe/London", 
    Hidden = false, 
    Color = "#2952A3", 
    Location = new Where("", "", "Location"), 
}; 

Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full"); 
CalendarEntry createdCalendar = (CalendarEntry)myService.Insert(postUri, calendar); 

有没有我可以用它来共享日历的一些其他方法或属性,在构造函数中,或者它被创建之后?我浏览过所有内容,但没有任何内容跳出来,一直在搜索并浏览这个网站,但没有运气。

我见过如何设置每个事件的访问级别的例子,可以单独尝试,但不能通过点击Google的日历设置来实现整个日历。

感谢

回答

1

发现任何人soution谁遇到这样的:

string postUristring = string.Empty; 

// note this could change in future! 
string feedString = createdCalendar.Id.AbsoluteUri.LastIndexOf("/") + 1; 
postUristring = feedString.Substring(0, feedString.Length - 28); 

AclEntry entry = new AclEntry(); 

entry.Scope = new AclScope(); 
entry.Scope.Type = AclScope.SCOPE_DEFAULT; 

entry.Role = new AclRole(); 
entry.Role = AclRole.ACL_CALENDAR_READ; 

Uri aclUri = new Uri("http://www.google.com/calendar/feeds/" 
      + postUristring + "@group.calendar.google.com" + "/acl/full"); 

AclEntry insertedEntry = myService.Insert(aclUri, entry); 
+0

这是值得注意的,因为你写了这个代码的子指数已经改变。 (或者至少现在对我来说已经不同了)。代码中的63的索引不再准确。为了弥补这一点,我目前将其设置为“LastIndexOf(”/“)+ 1”,但我想Google保留随时更改网址的权利。 – David 2012-05-25 18:42:39