iCalendar Open Source Lib for LiveCode

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

trevix
Posts: 389
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: iCalendar Open Source Lib for LiveCode

Post by trevix » Wed Jan 03, 2018 10:32 am

mmmh...
How would I go to convert to LC the following (used to retrieve a list of calendars):

Code: Select all

curl -v --header "Authorization: Bearer {YOUR_TOKEN_HERE}" \
    https://api.cronofy.com/v1/calendars
Do I need a curl library?
How much do I need to learn in order to use cUrl? (I am fine with json)

How come there is so little interest in the LC community on the ability to post Calendar data (sigh)? I know the sync is tough, but to be able to create a calendar event from a LC standalone on desktop and mobile, should be something appealing. Or not?

Thanks for answering.
Trevix

MaxV
Posts: 1547
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: iCalendar Open Source Lib for LiveCode

Post by MaxV » Wed Jan 03, 2018 1:15 pm

trevix wrote:
Wed Jan 03, 2018 10:32 am
mmmh...
How would I go to convert to LC the following (used to retrieve a list of calendars):

Code: Select all

curl -v --header "Authorization: Bearer {YOUR_TOKEN_HERE}" \
    https://api.cronofy.com/v1/calendars
Try this:

Code: Select all

--headers
put quote & "Authorization: Bearer YOURTOKEN" & quote & CRLF into tHeaders
set the httpHeaders to tHeaders
PUT URL "https://api.cronofy.com/v1/calendars"
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

trevix
Posts: 389
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: iCalendar Open Source Lib for LiveCode

Post by trevix » Thu Jan 04, 2018 4:17 pm

Tested with Postman and it works.
But (on LC 8.1.7,8.2,9.0 on OSX) I always get "tsneterr: HTTP response code 400 returned from server"

Code: Select all

on mouseUp pButtonNumber
    --clean up
    put empty into fld "TheError"
    put empty into fld "TheResult"
    --headers
    put quote & "Authorization: Bearer" && fld "TheToken" & quote  into tHeaders
    --put quote & "Authorization: Bearer" && fld "TheToken" & quote & CRLF into tHeaders
    set the httpHeaders to tHeaders
    get URL "https://api.cronofy.com/v1/calendars"
    --put URL "https://api.cronofy.com/v1/calendars" into fld "TheResult" of this card
    put it into fld "TheResult" of this card
    put the result into fld "TheError" of this card
end mouseUp
Trevix

MaxV
Posts: 1547
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: iCalendar Open Source Lib for LiveCode

Post by MaxV » Thu Jan 04, 2018 6:58 pm

A 400 means that the request was malformed. In other words, the data stream sent by the client to the server didn't follow the rules.

Probably you need to know what way your server want the data or the header.
You can use the libURLSetCustomHTTPHeaders command to create a perfect header compliant to the server, there are also a lot of libURL...

However try also this:

Code: Select all

put "Authorization: Bearer YOURTOKEN" & return into tHeaders
put "Accept: */*" after tHeaders
set the httpHeaders to tHeaders
put URL "theWebSite"
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

trevix
Posts: 389
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: iCalendar Open Source Lib for LiveCode

Post by trevix » Thu Jan 04, 2018 9:38 pm

Thanks.
Your last code worked, even if i am not sure of the difference (beside the quotes).

Trevix
Trevix

MaxV
Posts: 1547
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: iCalendar Open Source Lib for LiveCode

Post by MaxV » Fri Jan 05, 2018 12:59 pm

I just checked with the command:

Code: Select all

nc -lp 8070
what's the difference between the header of curl and the header of livecode.
the only differences are:
  • no quotes
  • Accept: */*

:D
Livecode Wiki: http://livecode.wikia.com
My blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w

trevix
Posts: 389
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: iCalendar Open Source Lib for LiveCode

Post by trevix » Sat Jan 06, 2018 6:42 pm

Thanks.

Getting back to the original topic (iCalendar Lib for Livecode), I have found this excellent first approach:

https://developer.apple.com/library/con ... 6-CH94-SW3

While Applescript does not work on iOS, I wonder if someone can arrange something with the Javascript, in order to give basic functionality to a Mobile standalone for adding, modifying and deleting events on the system calendar.

At Livecode there is a lot of talk about Widgets and Builder: Calendar and Contact interaction are the kind of functionalities that developer need, in my opinion.
Last edited by trevix on Sun Aug 12, 2018 11:11 am, edited 1 time in total.
Trevix

trevix
Posts: 389
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: iCalendar Open Source Lib for LiveCode

Post by trevix » Sun Aug 12, 2018 11:05 am

Ok, I guess not.

While waiting for answer from some expert, I tried another approach: using SQLite to read the Calendar Cache file on OSX.

I uploaded on LC Sample Stack a "lib_OSXCal" stack that does this: read calendar events from the Calendar Cache file, using SQLite.
I don't even know if this is correct or it messes up the calendar file (I guess reading is ok, while writing could be a problem).

The OSX "Calendar.app" also uses the "Write-Ahead Logging".
When you open Calendar.app you can sometimes see "Calendar Cache-wal" and "Calendar Cache-shm" files under the same path of the "Calendar Cache". I am having hard time finding on the web how these files work (you can't open them with a SQLite browser) , if they can mess out the SQLlite reading/writing or, for what I know, screw completely the Calendar.app database.

I would appreciate some comments or SQL improvement (I am a NOB on this).

Regards
Trevix
Attachments
lib_OSXCal.livecode.zip
(9.62 KiB) Downloaded 21 times
Trevix

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”