【问题标题】:How to add recurring entry Google Calendar如何添加定期条目谷歌日历
【发布时间】: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


【解决方案1】:

直接来自 Google(如果没有默认出现,请单击 .NET 示例):Create Recurring Events

如果不能完全正确地回答您的问题,希望这会给您一些想法。

干杯。

【讨论】:

  • 是的,这很好!我以前读过。唯一的问题是我需要通过 Google API 控制台注册我的应用程序。我试图找出另一种更简单的方法来做到这一点。我想我必须注册它!
【解决方案2】:

告诉它何时结束的重复字符串需要一个全职条目。您只是说 UNTIL=20131010。问题是20131010在哪里?我们可以假设你想要午夜,但是……午夜在哪里?

String recurData =
"RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20131010T000000-05:00;BYDAY=SU\r\n";

上述更改应该会使您的活动重复到 2013 年 10 月 10 日美国东部时间午夜。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-08
    • 1970-01-01
    相关资源
    最近更新 更多