5

我正在尝试获取用户默认日历提要的“正常”网址(例如http://www.google.com/calendar/feeds/jo@gmail.com/private/full)。我想使用 URL 的 jo@gmail.com 部分作为该日历的唯一 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。

4

2 回答 2

3

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

    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# 应该不会太难!

于 2010-03-02T10:47:18.570 回答
2

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++;
        }
于 2010-09-05T15:36:37.983 回答