我遇到的问题是我需要创建一个公开的Google日历。 我可以创建日历...但是然后我必须进入我的帐户并将日历公开。
我看了看API,看起来我需要创建一个AclRule以及可能的Scope()。我只是不确定如何将此规则应用于日历。
public static bool AddCalendar(string calendarName)
{
bool retVal = false;
UserCredential credential = GetCredential();
var service = new CalendarService(new BaseClientService.Initializer()
{ HttpClientInitializer = credential, ApplicationName = CalendarCredentials.ApplicationName, }); // Create Google Calendar API service.
Calendar calendar = new Calendar();
calendar.Summary = calendarName;
//// Create access rule with associated scope
//AclRule rule = new AclRule();
//rule.Scope.Type = "default";
//Scope scope = new Scope();
//scope.setType("scopeType").setValue("scopeValue");
//rule.setScope(scope).setRole("role");
try
{
Calendar createdCalendar = service.Calendars.Insert(calendar).Execute();
Con.Out("Adding:" + calendarName + " " + "Calendar Id:" + createdCalendar.Id);
retVal = true;
}
catch (Google.GoogleApiException ex)
{
Con.Out(ex.Error.Message);
}
return retVal;
}