本文整理汇总了C#中Google.GData.Calendar.CalendarService.SetAuthenticationToken方法的典型用法代码示例。如果您正苦于以下问题:C# CalendarService.SetAuthenticationToken方法的具体用法?C# CalendarService.SetAuthenticationToken怎么用?C# CalendarService.SetAuthenticationToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google.GData.Calendar.CalendarService
的用法示例。
在下文中一共展示了CalendarService.SetAuthenticationToken方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCalendarEvents
public static List<CalendarEvent> GetCalendarEvents(Calendar calendar)
{
List<CalendarEvent> eventList = new List<CalendarEvent>();
EventQuery query = new EventQuery();
CalendarService service = new CalendarService("GoogleCalendarReminder");
service.SetAuthenticationToken(GetAuthToken());
//service.setUserCredentials(Account.Default.Username
// , SecureStringUtility.SecureStringToString(Account.Default.Password));
query.Uri = new Uri(calendar.CalendarUri);
query.SingleEvents = true;
query.StartTime = DateTime.Now;
query.EndTime = DateTime.Today.AddDays(Settings.Default.DayRange);
EventFeed calFeed;
try
{
calFeed = service.Query(query) as EventFeed;
}
catch (Exception)
{
return null;
}
// now populate the calendar
while (calFeed != null && calFeed.Entries.Count > 0)
{
foreach (EventEntry entry in calFeed.Entries)
{
eventList.Add(new CalendarEvent(entry)
{
Color = calendar.Color
});
}
// just query the same query again.
if (calFeed.NextChunk != null)
{
query.Uri = new Uri(calFeed.NextChunk);
try
{
calFeed = service.Query(query) as EventFeed;
}
catch (Exception ex)
{
return null;
}
}
else
{
calFeed = null;
}
}
return eventList;
}
示例2: GetCalendarList
public static List<Calendar> GetCalendarList()
{
// Create a CalenderService and authenticate
var service = new CalendarService("GoogleCalendarReminder");
service.SetAuthenticationToken(GetAuthToken());
//service.setUserCredentials(Account.Default.Username, SecureStringUtility.SecureStringToString(Account.Default.Password));
var query = new CalendarQuery
{
Uri = new Uri("https://www.google.com/calendar/feeds/default/allcalendars/full")
};
CalendarFeed resultFeed;
try
{
resultFeed = service.Query(query) as CalendarFeed;
}
catch (CaptchaRequiredException ex)
{
// TODO: CDA - http://code.google.com/googleapps/faq.html
MessageBox.Show(ex.Message, ex.GetType().ToString());
//https://www.google.com/accounts/UnlockCaptcha
return null;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().ToString());
return null;
}
return (from CalendarEntry entry in resultFeed.Entries where !entry.Hidden select new Calendar(entry)).ToList();
}