【发布时间】:2013-02-27 01:05:01
【问题描述】:
我想用 C# 添加一个循环事件。我在网上发现以下应该可以工作。当我运行插入条目的方法时,它在 EventEntry insertEntry = service.Insert(calendarUri, entry);声明!
我收到此错误: “请求执行失败: https://www.google.com/calendar/feeds/user@gmail.com/private/full?gsessionid=6eGsOTuhQ-YUVWp2BV_25g"
当我删除重复代码时,一切正常!我注意到这段代码很老了!如何使用 .NET 库在 Google 日历上简单地添加定期事件?
EventEntry entry = new EventEntry();
entry.Title.Text = "Hello World !";
// Recurring event:
String recurData =
"RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20131010;BYDAY=SU\r\n";
Recurrence recurrence = new Recurrence();
recurrence.Value = recurData;
entry.Recurrence = recurrence;
string htmlDescription = "Woww, really ?";
if (htmlDescription != null && htmlDescription.Length > 0)
{
entry.Content.Type = "html";
entry.Content.Content = htmlDescription;
}
Where eventLocation = new Where();
eventLocation.ValueString = "Somewhere";
entry.Locations.Add(eventLocation);
DateTime start = DateTime.Now;
When eventTime = new When();
eventTime.StartTime = start;
DateTime endTime = DateTime.Now.AddHours(2);
eventTime.EndTime = endTime;
entry.Times.Add(eventTime);
eventTime.AllDay = true;
EventEntry insertedEntry = service.Insert(calendarUri, entry);
【问题讨论】:
-
“当我尝试它时,我得到一个错误。”除非您告诉我们“错误”是什么意思,否则对除您之外的所有人来说绝对没有意义。是编译器错误吗?运行时错误?错误发生在哪里?请编辑您的问题并解释您遇到的错误以及您看到的确切错误消息。期望我们通读您的代码并试图弄清楚这将使您获得帮助的速度慢得多。
-
对不起,你是对的!我用确切的错误进行了编辑,但对我来说,它仍然毫无意义。
标签: c# google-calendar-api recurring