views:

20

answers:

1

I've written a entry form for our company employees to enter marketing courses into the DB and at the same time add them to a Google Calendar. The Calendar is accepting the events, but the coloration of the event is different from a "manually" entered event using Google's interface. This leads me to believe that there is some property I am not setting that is causing the events not to be show on the calendar once it is embedded in our other company web pages.

The code used to enter events:

// Create a CalenderService and authenticate
CalendarService myService = new CalendarService("exampleCo-exampleApp-1");
myService.setUserCredentials("[email protected]", "xxxxxx");

CalendarQuery query = new CalendarQuery();
query.Uri = new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full");
CalendarFeed resultFeed = (CalendarFeed)myService.Query(query);

Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full");
foreach (CalendarEntry centry in resultFeed.Entries)
{
   litErrorMsg.Text += centry.Title.Text + "<br />";
   if (centry.Title.Text == "[email protected]")
   {
      postUri = new Uri("https://www.google.com/calendar/feeds/" +
         centry.SelfUri.ToString().Substring(centry.SelfUri.
         ToString().LastIndexOf("/") + 1) + "/private/full");
      break;
   }
}

Google.GData.Calendar.EventEntry entry = new Google.GData.Calendar.EventEntry(); 

// Set the title and content of the entry.
entry.Title.Text = eventName;
entry.Content.Content = eventName;
//entry.QuickAdd = true;
entry.EventVisibility = new Google.GData.Calendar.EventEntry.Visibility("event.public");

When eventTime = new When(Convert.ToDateTime(startDate), Convert.ToDateTime(endDate));
                entry.Times.Add(eventTime);

GDataGAuthRequestFactory requestFactory = (GDataGAuthRequestFactory)myService.RequestFactory;
requestFactory.CreateRequest(GDataRequestType.Insert, postUri);

// Send the request and receive the response:
AtomEntry insertedEntry = myService.Insert(postUri, entry);

And this is the resulting calendar:

alt text

The "test event jasdf event" is the manually entered event, and the two events: "Test event 234" are the programmatically entered events. In any case, once I embed the calendar, the only event showing up is the "test event jasdf".

I tried to manually set the event to PUBLIC but that didn't seem to help.

Anyone faced this issue before or had success with google calendar? If so, I'd like to see what you might have used to successfully create events and publish them.

Thanks!

A: 

Tom -

Have you figured this issue out yet? I'm thinking that you might be adding events to the wrong calendar... this would explain both of your problems:

  1. The events are colored differently because you're viewing multiple calendars simultaneously, and Google Calendar uses different colors for each calendar.

  2. Once you embed the single calendar that you think contains the events, you're only seeing the events that are actually on that specific calendar... hence, none of the events which were incorrectly placed.

The key here would be to check exactly which calendars you're viewing in the Google Calendar interface, and then look to see where the programmatically inserted events are ending up.

Matt
Alas, I have NOT figured out the issue. More disturbing is the fact that the google forums post has yet to return a response. So much for service of products.
TomO
Sorry, my comment ended early... the loop in the above code checks for the correct calendar, so I am pretty sure that's correct unless I am just misunderstanding how to use the API. There IS a privacy setting in each event, but the API offers no way to set that and if I read it correctly, events take on the inherited privacy setting of the calendar, in this case, shared publicly.
TomO