Google Calendar API:如何获取默认日历的 CalendarEntry?

发布于 2024-08-23 00:36:35 字数 1093 浏览 8 评论 0原文

我正在尝试获取用户默认日历源的“正常”网址(例如 http://www.google.com/calendar/feeds/[电子邮件受保护]/private/full)。我想使用网址的 [email protected] 部分作为该日历的唯一 ID。

我知道我可以使用 URL http://www 对默认日历执行操作.google.com/calendar/feeds/default/private/full。但是,我找不到从该 URL 构造 CalendarEntry 的方法(然后我可以尝试 SelfUri 和其他一些属性来查看“正常”url 是否在某处),或者将其转换为“正常”url以任何方式。

我知道我可以像这样获取日历列表:

CalendarQuery query_cal = new CalendarQuery();
query_cal.Uri = new Uri( "http://www.google.com/calendar/feeds/default/allcalendars/full" );
CalendarFeed resultFeed = (CalendarFeed) service.Query( query_cal );
foreach ( CalendarEntry entry in resultFeed.Entries )
{ ... }

但是,我找不到任何方法来知道哪些条目与默认日历匹配。

或任何其他方式获取默认日历的正常 URL。

I'm trying to get the 'normal' url for a users default calendar feed (e.g. http://www.google.com/calendar/feeds/[email protected]/private/full). I would like to use the [email protected] part of the URL as a unique ID for that calendar.

I know I can do things with the default calendar using the URL http://www.google.com/calendar/feeds/default/private/full. However, I can't find a way to construct a CalendarEntry from that URL (I could then try SelfUri and some other properties to see if the 'normal' url is in there somewhere), or to convert it to the 'normal' url in any way.

And I know I can get the list of Calendars like this:

CalendarQuery query_cal = new CalendarQuery();
query_cal.Uri = new Uri( "http://www.google.com/calendar/feeds/default/allcalendars/full" );
CalendarFeed resultFeed = (CalendarFeed) service.Query( query_cal );
foreach ( CalendarEntry entry in resultFeed.Entries )
{ ... }

However, I can't find any way to know which of those entries matches the default calendar.

Or any other way to get that normal url for the default calendar.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

燕归巢 2024-08-30 00:36:35

这可能不是最好的方法,但我使用它并且它有效:

    feedstring = resultfeed.Entries.Item(calendarIndex).Id.AbsoluteUri.Substring(63)
                postUristring = "https://www.google.com/calendar/feeds/" & feedstring & "/private/full"

Dim postUri As New Uri(postUristring)

只需将 calendarIndex = 0 用于默认日历。转换为 C# 应该不会太难!

It's probably not the best method, but I use this and it works:

    feedstring = resultfeed.Entries.Item(calendarIndex).Id.AbsoluteUri.Substring(63)
                postUristring = "https://www.google.com/calendar/feeds/" & feedstring & "/private/full"

Dim postUri As New Uri(postUristring)

Just use calendarIndex = 0 for the default calendar. Shouldn't be too hard to convert to C#!

撕心裂肺的伤痛 2024-08-30 00:36:35

太感谢了!效果非常好!这是我的最终代码:


        CalendarQuery query = new CalendarQuery();
        query.Uri = new Uri("https://www.google.com/calendar/feeds/default/allcalendars/full");
        CalendarFeed resultFeed = (CalendarFeed)service.Query(query);
        int calendarIndex = 0;
        string postUristring = string.Empty;
        foreach (CalendarEntry entry2 in resultFeed.Entries)
        {
            if (entry2.Title.Text == "My Pregnancy Calendar")
            {
                string feedstring = resultFeed.Entries[calendarIndex].Id.AbsoluteUri.Substring(63);
                postUristring = "https://www.google.com/calendar/feeds/" + feedstring + "/private/full";
            }
            calendarIndex++;
        }

Thank you SO much! That works perfectly! Here is my final code:


        CalendarQuery query = new CalendarQuery();
        query.Uri = new Uri("https://www.google.com/calendar/feeds/default/allcalendars/full");
        CalendarFeed resultFeed = (CalendarFeed)service.Query(query);
        int calendarIndex = 0;
        string postUristring = string.Empty;
        foreach (CalendarEntry entry2 in resultFeed.Entries)
        {
            if (entry2.Title.Text == "My Pregnancy Calendar")
            {
                string feedstring = resultFeed.Entries[calendarIndex].Id.AbsoluteUri.Substring(63);
                postUristring = "https://www.google.com/calendar/feeds/" + feedstring + "/private/full";
            }
            calendarIndex++;
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文