开发者

Google Calendar API: How to get a CalendarEntry for the default Calendar?

I'm trying to get the 'normal' url for a users default calendar feed (e.g. http://www.google.com/calendar/feeds/jo@gmail.com/private/full). I would like to use the jo@gmail.com 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 );开发者_C百科
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.


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#!


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++;
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜