0

I'm using the Google Calendar API to add a specific calendar and then add an event in it.

I'm able to do it only for one calendar. (my personnal calendar, logged with the API function : DoAuth()

I have 2 questions :

  1. How can I add the same event in another calendar at the same time ?
  2. Is it possible to execute DoAuth() without having the google log in window ?

Maybe I can use the API Key, but I can't figure how to code the authentification part.

Here is some basic code I made :

//-------------------------------------------------------------------------
//                  FORM CREATE
//-------------------------------------------------------------------------
procedure TForm1.FormCreate(Sender: TObject);
    begin
        AdvGCalendar1.DoAuth;
        Edit1.SetFocus();
    end;


//------------------------------------------------------------------------
//                  ADD CALENDAR
//-------------------------------------------------------------------------
    procedure TForm1.bt_ajouterCalendrierClick(Sender: TObject);
    var
    grem: TGReminder;

  begin
    Screen.Cursor := crHourGlass;
    gcal := AdvGCalendar1.Calendars.Add;
    gcal.Summary := 'Calendrier X';
    gcal.Description := 'Description X';
    gcal.Location := 'Locaux X';
    gcal.TimeZone := 'UTC';
    grem.Method := rmPopup;
    grem.Minutes := 60;
    grem := gcal.DefaultReminders.Add;

    AdvGCalendar1.AddCalendar(gcal);
    Screen.Cursor := crDefault;
  end;

//-------------------------------------------------------------------------
//                 GET INFOS EVENT
//-------------------------------------------------------------------------

    procedure TForm1.inputInfosRendezVous(Item: TGCalendarItem);
    var dateDebut, dateFin : TDateTime;
    begin
        Item.Summary := 'Test event';
        Item.Description := 'Test descirption';
        Item.Location := 'Test location';
        Item.Color := icBlue;
        Item.IsAllDay := false;
        Item.StartTime := PlannerCalendar1.Date;
        Item.EndTime := PlannerCalendar2.Date;
        Item.Visibility := viPublic;

    end;

//-------------------------------------------------------------------------
//                 ADD EVENT TO CALENDAR
//-------------------------------------------------------------------------
  procedure TForm1.bt_ajouterRendezVousClick(Sender: TObject);
  var
  event: TGCalendarItem;
  begin
    Screen.Cursor := crHourGlass;
    event := AdvGCalendar1.Items.Add;
    inputInfosRendezVous(event);
    event.CalendarID := gcal.ID;
    AdvGCalendar1.Add(event);
    Screen.Cursor := crDefault;
  end;

Thank you in advance for your help.

VirussInside
  • 187
  • 17
  • To be clear, you want to know how to add the same event to multiple calendars? If a search on "google add event to multiple calendars" doesn't help you should say why it does not. –  Oct 18 '17 at 14:53
  • The function DoAuth() opens me a Google log in window in order to grant acces to the calendar for my application. It's right I want to add the same event in another calendar but with the same connection. – VirussInside Oct 18 '17 at 15:00
  • How do the many references on the web not apply to your case? There seem to be recommended ways to do this already captured elsewhere. –  Oct 18 '17 at 15:02
  • that event word does not mean what it is [here](http://www.clevercomponents.com/articles/article038/) I think. That is an `TGCalendarItem` instance – Nasreddine Galfout Oct 18 '17 at 16:33
  • @jdv - I don't know, I can't find any good example of what I want to do on the web. What I want is : One account connected by DoAuth() creating an event to his calendar and also to another account's calendar. But I don't know how to do it at once. – VirussInside Oct 19 '17 at 08:28
  • Also isn't it possible to get all calendars from the account in order to fill a ComboBox for choosing in wich calendar I want to create the event ? edit : All example I found on web are for others languages, it's so hard to find good example for Delphi. – VirussInside Oct 19 '17 at 08:30

0 Answers0