tsnet on livecode server

Are you using LiveCode to create server scripts or CGIs?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
keliko
Posts: 53
Joined: Thu Aug 01, 2019 8:15 am

tsnet on livecode server

Post by keliko » Fri Aug 21, 2020 5:50 pm

how do i use tsnet on the livecode server. I use hostm and livecode business can you share code snippets.

thank you
Last edited by keliko on Fri Aug 21, 2020 8:06 pm, edited 1 time in total.

SparkOut
Posts: 2406
Joined: Sun Sep 23, 2007 4:58 pm

Re: tsnet on livecode server

Post by SparkOut » Fri Aug 21, 2020 6:43 pm

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.

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 121
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: tsnet on livecode server

Post by matthiasr » Fri Aug 21, 2020 7:04 pm

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
Last edited by matthiasr on Fri Aug 21, 2020 8:34 pm, edited 2 times in total.

keliko
Posts: 53
Joined: Thu Aug 01, 2019 8:15 am

Re: tsnet on livecode server

Post by keliko » Fri Aug 21, 2020 7:57 pm

Thanks Matthias and SparkOut
i will try it later.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 928
Joined: Fri Aug 15, 2008 7:15 am

Re: tsnet on livecode server

Post by bangkok » Sat Aug 22, 2020 2:40 am

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 ?
Last edited by bangkok on Sat Aug 22, 2020 5:46 am, edited 1 time in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8418
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: tsnet on livecode server

Post by FourthWorld » Sat Aug 22, 2020 4:27 am

Just curious: which tsNet features do you need on a server that aren't provided with libURL?
Richard Gaskin
LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

keliko
Posts: 53
Joined: Thu Aug 01, 2019 8:15 am

Re: tsnet on livecode server

Post by keliko » Sat Aug 22, 2020 5:47 am

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.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 928
Joined: Fri Aug 15, 2008 7:15 am

Re: tsnet on livecode server

Post by bangkok » Sat Aug 22, 2020 5:50 am

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).

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8418
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: tsnet on livecode server

Post by FourthWorld » 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.
Richard Gaskin
LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 121
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: tsnet on livecode server

Post by matthiasr » Sat Aug 22, 2020 8:01 am

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

SparkOut
Posts: 2406
Joined: Sun Sep 23, 2007 4:58 pm

Re: tsnet on livecode server

Post by SparkOut » Sat Aug 22, 2020 8:26 am

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.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 928
Joined: Fri Aug 15, 2008 7:15 am

Re: tsnet on livecode server

Post by bangkok » Sat Aug 22, 2020 9:18 am

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.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8418
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: tsnet on livecode server

Post by FourthWorld » Sat Aug 22, 2020 4:18 pm

SMTP is good that way. If you need anything in the MS APIs that require OAuth please keep me posted.
Richard Gaskin
LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “CGIs and the Server”