04.11.2016, 20:40
Hello,
How can I send POST command "POST /relay/0?turn=on" from lua script?
Thanks
Deso
How can I send POST command "POST /relay/0?turn=on" from lua script?
Thanks
Deso
HTTP Post
|
04.11.2016, 20:40
Hello,
How can I send POST command "POST /relay/0?turn=on" from lua script? Thanks Deso
05.11.2016, 11:25
One of these requests should work for you, don't forget to change the IP address as required.
Code: local http = require('socket.http')
05.11.2016, 20:39
Thanks, it work. Is there any manual or examples about http post and get?
07.11.2016, 07:17
Here's the library reference:
http://w3.impa.br/~diego/software/luasoc...ml#request
09.05.2019, 08:46
(07.11.2016, 07:17)admin Wrote: Here's the library reference: Hello Admin, I would like to send by order on a second LM or on another box (Box TV) i use this script but the command is not sent. I indicate the IP and the password but the request is not sent. I try directly in the browser and it works. these scripts are still functional? local http = require('socket.http') http.request('http://remote:remote@IP/scada-remote?m=json&r=grp&fn=write&alias=34/1/2&value=1', '') thanks. B.R.
09.05.2019, 09:10
Hi
Are you referring to remote services? Sure they work, fallow this https://forum.logicmachine.net/showthrea...09#pid3009 BR
------------------------------
Ctrl+F5
09.05.2019, 10:09
Add log call to see what the web server returned in Logs tab:
Code: local http = require('socket.http')
09.05.2019, 11:37
(09.05.2019, 10:09)admin Wrote: Add log call to see what the web server returned in Logs tab:Can be then admin login request ? Log : * arg: 1 * nil * arg: 2 * string: connection refused
09.05.2019, 11:53
Connection refused means that URL has incorrect IP or port (optional, default 80). Can you ping that IP from System config > Status > Network utilities?
09.05.2019, 12:10
(09.05.2019, 11:53)admin Wrote: Connection refused means that URL has incorrect IP or port (optional, default 80). Can you ping that IP from System config > Status > Network utilities? it works with the local IP but not the public one I do not know why. I continue my tests. With the FREEPLAYER i have : * arg: 1 * string: * arg: 2 * number: 403
09.05.2019, 12:18
Do you mean that you use port forwarding? Are two devices in the same sub-network and you want to access another device via port-forwarded IP?
09.05.2019, 12:55
(09.05.2019, 12:18)admin Wrote: Do you mean that you use port forwarding? Are two devices in the same sub-network and you want to access another device via port-forwarded IP? No for example I have an LM in the same network as the player freebox and I would like to drive via the LM this player. So I have the following script (For the remote I did my tests for sending URLs because it did not work with the player, to be sure I was not wrong in the scripts). Code: local http = require('socket.http') When I realize it directly in my browser it works.
09.05.2019, 13:05
Your URL has http:// twice and there's a double quote character in code argument: code=CODETELECOMMAND"
09.05.2019, 13:18
(09.05.2019, 13:05)admin Wrote: Your URL has http:// twice and there's a double quote character in code argument: code=CODETELECOMMAND" Yes i have a single http lack of copy. it's the " who's causing the problem... (Sorry for making you waste yout time !!!!) it works perfectly. One las question concerning all of thse commands how can i easily reduce the script and not put if 1 then play if 2 then power if 3 .... etc... can we recover the names of the custom values in order to put in my URL according to the command achieve? Thanks a lot. BR.
09.05.2019, 13:28
There's no easy way of accessing custom values. But you can create a table with number - key mapping:
Code: keys = {
09.05.2019, 14:20
(09.05.2019, 13:28)admin Wrote: There's no easy way of accessing custom values. But you can create a table with number - key mapping: Thank you again for your answers. B.R.
Hi !!!
Please, whear can I put the script for Http POST ??? In Resident ??? I have seen this: https://forum.logicmachine.net/showthread.php?tid=453 local http = require('socket.http') -- empty post body http.request('http://192.168.1.1/relay/0?turn=on', '') -- post instead of get http.request('http://192.168.1.1/relay/0', 'turn=on') Thanks in advance for your answer Regards
11.09.2023, 11:06
It depend of the application but it can be simple event script.
------------------------------
Ctrl+F5
13.09.2023, 14:11
|
« Next Oldest | Next Newest »
|