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: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

trevix
Posts: 373
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: 1489
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: 373
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: 1489
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: 373
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: 1489
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: 373
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: these are the kind of functionalities that developer need, in my opinion.
Trevix

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”