Page 1 of 1

tsnet on livecode server

Posted: Fri Aug 21, 2020 5:50 pm
by keliko
how do i use tsnet on the livecode server. I use hostm and livecode business can you share code snippets.

thank you

Re: tsnet on livecode server

Posted: Fri Aug 21, 2020 6:43 pm
by SparkOut
You have to download the server version from the store part of your login to the LiveCode website to use tsnet on server. The community version on the public downloads site will not work.

If you use https or encryption, you also need to ensure that you upload the cert folder to the server.

In the LC server script, you need to initialise the tsNet library before making any tsNet calls. (And close afterwards for good housekeeping.)

I might be able to get some more specific script snippets later when I am not just using this phone, but that should hopefully give you a start.

Re: tsnet on livecode server

Posted: Fri Aug 21, 2020 7:04 pm
by matthiasr
I use hostm and business livecode can you share code snippets.
If you can proof that you have a legal license of Livecode Server Business then the people at HostM will install the Business version of Livecode Server for your HostM account. No need to download and install it manually.

As SparkOut already mentioned, you have to run tsInit to initalize tsNet before you can use it.

The following script downloads the Release Notes for LC 9.6.1 from the Livecode Server and stores it in the public_html folder.

Code: Select all

<?lc
tsnetinit
put the home folder &"/public_html/LiveCodeNotes-9_6_1.pdf" into pFile
put "https://livecodestatic.com/downloads/livecode/9_6_1/LiveCodeNotes-9_6_1.pdf" into pURL
put tsNetGetFileSync(pFile, pURL, xHeaders, rOutHeaders, rBytes,)

?>
and this one for example downloads the PDF from Livecode Server and "pushes" it to your browser as a download.

Code: Select all

<?lc
tsnetinit
put "https://livecodestatic.com/downloads/livecode/9_6_1/LiveCodeNotes-9_6_1.pdf" into pURL
put tsNetGetSync(pURL, xHeaders, rOutHeaders, rResult, rBytes,) into tData
        
put "LiveCodeNotes-9_6_1.pdf" into tFile
put header "Content-Type: application/octet-stream"
put new header "Content-Disposition: attachment; FileName=" & tFile
put tData
?>

Regards,
Matthias

Re: tsnet on livecode server

Posted: Fri Aug 21, 2020 7:57 pm
by keliko
Thanks Matthias and SparkOut
i will try it later.

Re: tsnet on livecode server

Posted: Sat Aug 22, 2020 2:40 am
by bangkok
Very interesting.

I just ask HostM to do the "upgrade" on my account (they did it a few minutes, after sending them my invoice of LC Indy, amazing).

One question though : "(And close afterwards for good housekeeping.)"

You mean after every TSNet command within a lc server script, we have to close ? with tsNetClose ?

Re: tsnet on livecode server

Posted: Sat Aug 22, 2020 4:27 am
by FourthWorld
Just curious: which tsNet features do you need on a server that aren't provided with libURL?

Re: tsnet on livecode server

Posted: Sat Aug 22, 2020 5:47 am
by keliko
I just want to try tsNet external on the server although it can be done with libURL.
and it turned out that the livecode was amazing. I can be a fullstack.with syntax like English language.

Re: tsnet on livecode server

Posted: Sat Aug 22, 2020 5:50 am
by bangkok
FourthWorld wrote:
Sat Aug 22, 2020 4:27 am
Just curious: which tsNet features do you need on a server that aren't provided with libURL?
I will answer for myself : i do not know... yet ;-)

I just want to do experiments.

Something might be easier with tsNet though : sending email (with a third party account, like microsoft 365 office).

Re: tsnet on livecode server

Posted: Sat Aug 22, 2020 7:30 am
by FourthWorld
If you get the authentication part of that *office 365 integration down please let me know. MS seems to have some oddly cumbersome config for their OAuth2 setup.

Re: tsnet on livecode server

Posted: Sat Aug 22, 2020 8:01 am
by matthiasr
FourthWorld wrote:
Sat Aug 22, 2020 4:27 am
Just curious: which tsNet features do you need on a server that aren't provided with libURL?
I can just speak for myself.
We are running several cronjobs (livecode server scripts) for file backup, MySQL DB cleaning and other maintenance stuff.
Wnile php has smtp and ftp libraries, Livecode server cannot do such things out of the box using just liburl. There are no libraries for SMTP over TLS or SFTP/FTPes available.
So we are using tsNet with LivecodeServer currently for
1. sftp/FTPes file transfers
2. sending notification emails

Matthias

Re: tsnet on livecode server

Posted: Sat Aug 22, 2020 8:26 am
by SparkOut
As for me, my need for tsNet on server is to securely fetch dealers, product info and stock levels from brand owner's site, which is then parsed to update the various individual brand sites. Until tsNet, this had to be shelled out to wget or curl.

Re: tsnet on livecode server

Posted: Sat Aug 22, 2020 9:18 am
by bangkok
FourthWorld wrote:
Sat Aug 22, 2020 7:30 am
If you get the authentication part of that *office 365 integration down please let me know. MS seems to have some oddly cumbersome config for their OAuth2 setup.
Well that's my point.

With createSmtpMessage and tsNetSmtpSync and
put true into tSettings["use_ssl"]
and using the Microsoft SMTP server : smtp://smtp.office365.com:587

I can send an email from a 365 office account email address, from a desktop app !

That's not a project, nor an idea. It works. ;-)

This is why i was thinking about this, with LC server.

Re: tsnet on livecode server

Posted: Sat Aug 22, 2020 4:18 pm
by FourthWorld
SMTP is good that way. If you need anything in the MS APIs that require OAuth please keep me posted.