有没有办法更改Google日历的访问权限级别?

时间:2011-03-16 18:30:45

标签: .net google-calendar-api

我有以下代码为gmail联系人创建新日历:

// Create a CalenderService and authenticate
CalendarService myService = new CalendarService("exampleCo-exampleApp-1");
myService.setUserCredentials("email@email.com", "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 个答案:

答案 0 :(得分:1)

为遇到此问题的人找到了解决方案:

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);