Page 2 of 2
Re: Problems with HTML5 standalone (psychology experiment)
Posted: Tue Oct 06, 2020 11:21 am
by MarBor
richmond62 wrote: Thu Oct 01, 2020 6:29 pm
Why not have the results posted in a text file to your email address?
Sorry for the delayed reply ...
That is actually a very good idea, too.
However, how would I do this?
Would you send me some code fragment that would do this job?
It would be highly appreciated!
Re: Problems with HTML5 standalone (psychology experiment)
Posted: Wed Oct 07, 2020 8:14 am
by richmond62
You are more than welcome to "fiddle about" with this:
-
-
Be warned: IF you click on the button it will send me your MAC address.
https://www.dropbox.com/s/5qz9l86wv66hj ... e.zip?dl=0
Re: Problems with HTML5 standalone (psychology experiment)
Posted: Wed Oct 07, 2020 12:06 pm
by MarBor
Thanks a lot!
I managed to send the results in an email to myself with this from the app run in the LC IDE. I will try now from the HTML5 app.
It's maybe not optimal that an email client needs to be opened so that the participant needs to click on "send", though.
I also know some people who don't use/configure their email account in client software.
But this solution will definitely be a sufficient one in case I don't manage to get this post to PHP server solution to work.
Re: Problems with HTML5 standalone (psychology experiment)
Posted: Wed Oct 07, 2020 2:46 pm
by MarBor
MarBor wrote: Wed Oct 07, 2020 12:06 pm
Thanks a lot!
I managed to send the results in an email to myself with this from the app run in the LC IDE. I will try now from the HTML5 app.
It's maybe not optimal that an email client needs to be opened so that the participant needs to click on "send", though.
I also know some people who don't use/configure their email account in client software.
But this solution will definitely be a sufficient one in case I don't manage to get this post to PHP server solution to work.
Some news:
1)
I've tried it in HTML5 now, too, and in the HTML5 standalone version no email client software is opened and no email can be sent.
2)
I've now also tried around a bit with the POST solution. I included some code in my LC app to post the text file and I created a PHP file for the server (which is most likely the weak link, since I have no experience with server side stuff and PHP at all).
I ended up with the following code (adopted from LiveCode WIKI on keyword LibURLMultipartFormData) on my last card in the experiment:
Code: Select all
local tForm, tError, tUrl, tName, tMessage, tFile
put empty into tForm
put "http://myserver/specificdirectory/phpfile" into tUrl
put "someone" into tName -- not necessary ?
put "something" into tMessage -- not necessary ?
put "<file>" & fname & "/myFile[dot]txt" into tFile -- the file I want to send (fname - the file directory - was defined before in my script)
put libURLMultipartFormData \
(tForm, "name", tName, "message", tMessage, "file", tFile) \
into tError
if tError is not empty then
answer tError
else
set the httpHeaders to line 1 of tForm
post line 2 to -1 of tForm to url tUrl
## check the result, etc, here
set the httpHeaders to empty
end if
My PHP file is supposed to store what is posted to it in some directory on the server. Due to my lack of knowledge the script probably won't do that. It could also be the case that there is some issue with writing permission on the server ...
But I first wanted to check with some working target server whether stuff is actually posted from my LC app.
So I used the great website "Post Test Server V2" and from both the app run in the LC IDE and the windows standalone my text file is really posted to the target "toilet" (

) on Post Test Server V2.
But absolutely nothing arrives there when running the HTML5 standalone of the same app (but there's also no error message). I checked in the dictionary: libURLMultipartFormData is available for HTML5. Just as indicated in the dictionary entry I included the Internet library when generating the standalone.
Why doesn't it work in the HTML standalone?
Re: Problems with HTML5 standalone (psychology experiment)
Posted: Wed Oct 07, 2020 5:53 pm
by richmond62
Ouch . . .
-
-
Here's a thought . . .
Check out "
mimeEncodeAsMIMEEmail" in the Documentation.

Re: Problems with HTML5 standalone (psychology experiment)
Posted: Thu Oct 08, 2020 9:35 am
by MarBor
richmond62 wrote: Wed Oct 07, 2020 5:53 pm
Ouch . . .
-
Screenshot 2020-10-07 at 19.53.11.png
-
Here's a thought . . .
Check out "
mimeEncodeAsMIMEEmail" in the Documentation.
As far as I understand this one you just prepare the email/data for sending with the tsNetSmtpSync function, which according to the dictionary is not available for HTML5 and requires one of the non-free Livecode editions.

Re: Problems with HTML5 standalone (psychology experiment)
Posted: Thu Oct 08, 2020 10:50 am
by richmond62
Unfortunately, as far as I can tell, HTML5 LiveCode is not feature complete.
Re: Problems with HTML5 standalone (psychology experiment)
Posted: Fri Oct 09, 2020 10:14 am
by MarBor
MarBor wrote: Wed Oct 07, 2020 2:46 pm
Some news:
2)
I've now also tried around a bit with the POST solution. I included some code in my LC app to post the text file and I created a PHP file for the server (which is most likely the weak link, since I have no experience with server side stuff and PHP at all).
I ended up with the following code (adopted from LiveCode WIKI on keyword LibURLMultipartFormData) on my last card in the experiment:
Code: Select all
local tForm, tError, tUrl, tName, tMessage, tFile
put empty into tForm
put "http://myserver/specificdirectory/phpfile" into tUrl
put "someone" into tName -- not necessary ?
put "something" into tMessage -- not necessary ?
put "<file>" & fname & "/myFile[dot]txt" into tFile -- the file I want to send (fname - the file directory - was defined before in my script)
put libURLMultipartFormData \
(tForm, "name", tName, "message", tMessage, "file", tFile) \
into tError
if tError is not empty then
answer tError
else
set the httpHeaders to line 1 of tForm
post line 2 to -1 of tForm to url tUrl
## check the result, etc, here
set the httpHeaders to empty
end if
My PHP file is supposed to store what is posted to it in some directory on the server. Due to my lack of knowledge the script probably won't do that. It could also be the case that there is some issue with writing permission on the server ...
But I first wanted to check with some working target server whether stuff is actually posted from my LC app.
So I used the great website "Post Test Server V2" and from both the app run in the LC IDE and the windows standalone my text file is really posted to the target "toilet" (

) on Post Test Server V2.
But absolutely nothing arrives there when running the HTML5 standalone of the same app (but there's also no error message). I checked in the dictionary: libURLMultipartFormData is available for HTML5. Just as indicated in the dictionary entry I included the Internet library when generating the standalone.
Why doesn't it work in the HTML standalone?
Quick update on the progress with the approach of posting something to a server:
In the meantime I managed to send some string to the
Post Test Server V2 from the HTML5 standalone via the
Code: Select all
do 'some_JavScript_code_as_string' as "Javascript"
function.
My code looks like this:
Code: Select all
local tScript
local someVariable
put "some LiveCode string" into someVariable
put "var xhr = new XMLHttpRequest();" & cr & \
"xhr.open(" & quote & "POST" & quote & \
", " & quote & "http://ptsv2.com/t/0azk7-1602160959/post" & quote & ", true);" & cr & \
"xhr.setRequestHeader(" & quote & "Content-Type" & quote & \
", " & quote & "application/x-www-form-urlencoded; charset=UTF-8" & quote & ");" & cr & \
"xhr.send('" & someVariable & "');" into tScript
do tScript as "JavaScript"
['
http://ptsv2.com/t/0azk7-1602160959/post' is the server url - in my case my specific randomly chosen "toilet" on
Post Test Server V2]
By this I really received "some LiveCode string" on the test website.
Now I probably only have to adjust the setRequestHeader() arguments to the accurate content type and to figure out the optimal format of the send() body. And I have to set up my server with an appropriate PHP script (I got some help for that

)
I will keep you posted about my progress - maybe it can be of help for someone else.
Re: Problems with HTML5 standalone (psychology experiment)
Posted: Tue Oct 13, 2020 10:34 am
by thatkeith
MarBor wrote: Fri Oct 09, 2020 10:14 am
I will keep you posted about my progress - maybe it can be of help for someone else.
Thanks for following this through here as well as in your actual project! It's always helpful to read what ends up working when there's been this sort of back-and-forth. I look forward to learning of your project's full success.
k
Re: Problems with HTML5 standalone (psychology experiment)
Posted: Mon Oct 26, 2020 4:26 pm
by MarBor
thatkeith wrote: Tue Oct 13, 2020 10:34 am
Thanks for following this through here as well as in your actual project! It's always helpful to read what ends up working when there's been this sort of back-and-forth. I look forward to learning of your project's full success.
Thank you - I'm happy to hear that it is appreciated
