views:

283

answers:

2

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.

A: 

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

I saw too that the default calender was index 0 in my searches, but I find no reference to this anywhere. So I guess that tomorrow, google could change it's mind and put it last (e.g. for performance reasons)?
Legolas
A: 

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