Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-07

Google Calendar APIs

7 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marcello

Hi all

I'm trying to create a event on a google calendar. Starting from "calendardemo" I create a new procedure to test my code and a button to execute.

Following code works properly: after execution I can see the event using a browser.

I know that recently a bug was closed
(http://bugs.freepascal.org/view.php?id=29487) but I do not think it is the same problem.
Any suggestions?

Thanks

Marcello

procedure TMainForm.Insert;
var Entry: TEvent;
begin
   Entry:=TEvent.Create();
   try
     Entry.id := 'aaa' + FormatDateTime('yyyymmddhhnnss', Now);
     Entry.summary:=Format('test event: %s', [Entry.id]);
     Entry.description:='empty description, yeah!';
     Entry.location:='a location';
     Entry.start := TEventDateTime.Create();
     Entry.start.dateTime:= ComposeDateTime(EncodeDate(2016,7,16),EncodeTime(23 -2,0,0,0));
     Entry.start.timeZone:='Europe/Rome';
     Entry._end := TEventDateTime.Create();
     Entry._end.dateTime := ComposeDateTime(EncodeDate(2016,7,16),EncodeTime(23 -2,10,0,0));
     Entry._end.timeZone:='Europe/Rome';
     SaveRefreshToken;
     FCalendarAPI.EventsResource.Insert(FCurrentCalendar.ID, Entry);
   finally
     Entry.Free;
   end;
end;

Follow request.log

--------------------------------------------------------------------------------

Request : POST https:/events

Headers:

Content-type:application/json

Authorization: Bearer ya29.CjUnA_TOUWN8YvS8KjqYqFtrIyfJEQPJkyrl36V4LuM8T90b6qwMKJ0j4kTsx3YrW42QKF0MAg

Body:

{ "description" : "empty description, yeah!", "end" : { "dateTime" : "2016-07-16T21:10:00.000Z", "timeZone" : "Europe\/Rome" }, "id" : "aaa20160721160146", "location" : "a location", "start" : { "dateTime" : "2016-07-16T21:00:00.000Z", "timeZone" : "Europe\/Rome" }, "summary" : "test event: aaa20160721160146" }

Trying multiple protocols.

--------------------------------------------------------------------------------

Response : 200 : OK

Headers:

Cache-Control: no-cache, no-store, max-age=0, must-revalidate

Pragma: no-cache

Expires: Mon, 01 Jan 1990 00:00:00 GMT

Date: Thu, 21 Jul 2016 14:01:46 GMT

Vary: X-Origin

Content-Type: application/json; charset=UTF-8

X-Content-Type-Options: nosniff

X-Frame-Options: SAMEORIGIN

X-XSS-Protection: 1; mode=block

Server: GSE

Alternate-Protocol: 443:quic

Alt-Svc: quic=":443"; ma=2592000; v="36,35,34,33,32,31,30,29,28,27,26,25"

Accept-Ranges: none

Vary: Origin,Accept-Encoding

Transfer-Encoding: chunked

Body:

{

"kind": "calendar#event",

"etag": "\"2938219412944000\"",

"id": "aaa20160721160146",

"status": "confirmed",

"htmlLink": "https://www.google.com/calendar/event?eid=YWFhMjAxNjA3MjExNjAxNDYgbWFnZ2lvcmRvbW80bUBt",

"created": "2016-07-21T14:01:46.000Z",

"updated": "2016-07-21T14:01:46.472Z",

"summary": "test event: aaa20160721160146",

"description": "empty description, yeah!",

"location": "a location",

"creator": {

"email": "",

"self": true

},

"organizer": {

"email": "",

"self": true

},

"start": {

"dateTime": "2016-07-16T23:00:00+02:00",

"timeZone": "Europe/Rome"

},

"end": {

"dateTime": "2016-07-16T23:10:00+02:00",

"timeZone": "Europe/Rome"

},

"iCalUID": "",

"sequence": 0,

"reminders": {

"useDefault": true

}

}

Reply by email

Marcello
to Marcello
Marcello wrote
Following code works properly: after execution I can see the event using a browser.

Forgive me
code works propery but, closing the application, heaptrace shows many laks

Regards
Marcello

Reply by email

Michael Van Canneyt
to Marcello
Marcello wrote 7 lines
On 21/07/2016 16:09, Marcello wrote: > > Following code works properly: after execution I can see the event > using a browser. Forgive me code works propery but, closing the application, heaptrace shows many laks

Memory leaks have been fixed meanwhile, so it should work with the latest source ?

Michael.

Reply by email

Michael Van Canneyt
to Marcello
Marcello wrote 16 lines
On 21/07/2016 21:42, Michael Van Canneyt wrote: > > Memory leaks have been fixed meanwhile, so it should work with the > latest source ? > > Michael. I was compiling with fpc 3.0.0, this aren't latest source. Looking here http://bugs.freepascal.org/view.php?id=29487 I can find Fixed in Version => 3.1.1 Target Version => 3.0.2 This mean I can use fixes or trunk?

trunk, to be sure.

Michael.

Reply by email

Marcello
to Michael Van Canneyt
Michael Van Canneyt wrote
trunk, to be sure. Michael.

Now I'm using fpc trunk but there's something wrong.

To try with latest source, I've installed lazarus 1.6 and, in another folder (using fpcup), the fpc trunk.
After this I configured lazarus to use the fpc trunk compiler (and fpc-source-folder-option points to correct folder).

calendardemo is compiled without errors, but simply clicking on "fetch calendars" I got following error.

Any suggestion?

Thanks

Marcello Basso

C:\lazarus\components\googleapis\demo\calendar>calendardemo.exe TApplication.HandleException Cannot convert data from object value Stack trace:
$0000000100149857
$000000010014C51C
$000000010014C88F
$000000010014B20A
$000000010018786A
$0000000100187E8C
$0000000100189FF2
$000000010018A276
$0000000100181685
$0000000100180D86
$0000000100185960
$000000010002E811 BFETCHCALENDARSCLICK, line 203 of frmmain.pp $0000000100127627 CLICK, line 2736 of include/control.inc $0000000100140689 CLICK, line 54 of include/buttoncontrol.inc $0000000100140D7A CLICK, line 169 of include/buttons.inc $0000000100140565 WMDEFAULTCLICKED, line 20 of
include/buttoncontrol.inc
$000000010000DEB6
Heap dump by heaptrc unit
159046 memory blocks allocated : 19189753/19198024 159046 memory blocks freed : 19189753/19198024 0 unfreed memory blocks : 0
True heap size : 229376 (192 used in System startup) True free heap : 229184

Reply by email

Michael Van Canneyt
to Marcello
Marcello wrote 18 lines
On 26/07/2016 09:46, Michael Van Canneyt wrote: > > trunk, to be sure. > > Michael. Now I'm using fpc trunk but there's something wrong. To try with latest source, I've installed lazarus 1.6 and, in another folder (using fpcup), the fpc trunk. After this I configured lazarus to use the fpc trunk compiler (and fpc-source-folder-option points to correct folder). calendardemo is compiled without errors, but simply clicking on "fetch calendars" I got following error. Any suggestion?

No. This needs to be debugged.

Michael.

Reply by email