0
Answer

How to Create Events on Friend's Google Calendar

Ask a question
Satish

Satish

11y
1.4k
1
Hi,

I have ten friends. I want to Create Events to all my friend's Google primary Calendar using .net client library.
For that i've downloaded .net client library using following URL:https://developers.google.com/google-apps/calendar/v2/developers_guide_dotnet  
I requested my friends to share their calendar to me and to give access permission to me to post events on their calendar.
Can any one clarify my doubts which i mentioned with Numbers with in my sample code??


This is my Sample Code 
----------------------------------
    using Google.GData.AccessControl;
    using Google.GData.Calendar;
    using Google.GData.Client;
    using Google.GData.Extensions;

    Namespace xxxxxxx
    {
    class GoogleCal
      {
       public void CreateEvent()
          {
           
            try
             {
               string feedURI = "https://www.google.com/calendar/feeds/[email protected]/private/full";
  CalendarService service = new CalendarService("Test");
  service.setUserCredentials(username, password); ---------------> 1 ( How to get the Status??)

                CalendarQuery query = new CalendarQuery();
              
                EventEntry entry = new EventEntry();
               
                
                // Set the title and content of the entry.
                entry.Title.Text = entryTitle;
                entry.Content.Content = content;
               
                  // Set a location for the event.
                Where eventLocation = new Where();
                eventLocation.ValueString = location;
                entry.Locations.Add(eventLocation);

                // If a recurrence was requested, add it.  Otherwise, set the
                // time (the current date and time) and duration (30 minutes)
                // of the event.
                if (recurData == null)
                {
                    When eventTime = new When();
                   eventTime.StartTime = DateTime.Now;
                    eventTime.EndTime = eventTime.StartTime.AddMinutes(40);                    
                    entry.Times.Add(eventTime);
                }
                else
                {
                    Recurrence recurrence = new Recurrence();
                    recurrence.Value = recurData;
                    entry.Recurrence = recurrence;
                }

                // Send the request and receive the response:
                Uri postUri = new Uri(feedURI);
                AtomEntry insertedEntry = service.Insert(postUri, entry); -------------------->2 (How to get the Status if one of my friend remove the access permission to me??)
                en = (EventEntry)insertedEntry;
                string s = en.EventId;
           

            }

            catch (Exception ee)
            {
                throw ee;
             }
          }
           
       }
  
     }

1. How to catch the Exception while setting the user credentials to service whether it is fail or success(Invalid Credentials)
2. After some days one of my friend may remove the access permission to me with out intimation. But i'm trying to push events to his calendar then that time how to trace that exception.
3. When i post event to my friend's calendar then his calendar also is listing in my calendars list. How to avoid this to list under my calendars list.
4. I've read usage limits of Google Calendar from following URL:http://support.google.com/a/bin/answer.py?hl=en&answer=2905486.
   Will this "Creating too many calendars" problem will be applicable to me  because all my friends calendars are listing under my calendars list???

Can any one Please suggest me the better way to achieve this if it is not the correct way to post events on others calendar???