Search code examples
google-data-api

Google Data API


Two questions:

How do you get events from a specific Calendar? The following link gets events for your primary calendar: http://www.google.com/calendar/feeds/user@gmail.com/private/full .

And how do you get a contact's birth date from the list of ContactEntry objects that is returned to you when using the ContactsService?

Thanks in advance!


Solution

  • I should probably provide some of my findings in-case somebody else wants to know this. As far as getting the dates from public calendars are concerned, the CalendarEntry class contains a generic list of AtomLink objects. The very first one's AbsoluteUri property will provide you with the EventEntry objects for that calendar. Here is some sample code:

      foreach (CalendarEntry c in calendars)
      {
        Console.WriteLine(c.Title.Text);
        if (c.Links.Count > 0)
        {
          AtomLink link = c.Links[0];
          EventQuery query = new EventQuery();
          query.Uri = new Uri(link.AbsoluteUri);
          query.FutureEvents = true;
    
          // Tell the service to query:
          EventFeed calFeed = service.Query(query);
          foreach (EventEntry entry in calFeed.Entries)
          {
            Console.WriteLine(entry.Title.Text);
            foreach (When w in entry.Times)
              Console.WriteLine("\t" + w.StartTime);
          }
        }
        else
          Console.WriteLine("...no data found.");
    
        Console.ReadKey();
        Console.Clear();
      }
    

    I still don't know how to get the Contact's birth date :/ I'll have a look at that when I have more time.