airsoftsoftwair wrote: ↑Sat Nov 09, 2019 12:40 pm
The syntax posted by p-OS is definitely the correct way to do it. There's no "PostData" tag, it's called "Post". Please post a minimal test script with a real URL that I can test here...
Here's an example using an external server (I was testing with a local server but the outcome is the same as the error happens before the function establishes the connection)
Code: Select all
@DISPLAY {Mode = "Windowed", Height = 500, Width = 500}
data$, bytes = DownloadFile("http://am1ga.com/cgi-bin/myip.cgi", {Post = "a=1"})
Print(data$ .. "\n" .. bytes)
WaitLeftMouse()
Here it gives the error: "Wrong usage/parameters for this command!"
This GET request works:
Code: Select all
data$, bytes = DownloadFile("http://am1ga.com/cgi-bin/myip.cgi")
the CGI script returns my IP
This GET request with key pairs too:
Code: Select all
data$, bytes = DownloadFile("http://am1ga.com/cgi-bin/myip.cgi?a=1&b=2")
the CGI script returns my IP and additional details about the request.
It's only the POST requests which don't work here.
BTW, I'm running Hollywood 8 on OS4.1/A1-XE. I should try on another platform to see if it behaves differently.
The long way around to submit a POST request works:
Code: Select all
postdata = "a=1&b=2"
OpenConnection(1, "am1ga.com", 80)
SendData(1, "POST http://am1ga.com/cgi-bin/myip.cgi HTTP/1.0\r\n" ..
"Content-Length: " .. StrLen(postdata) .. "\r\n\r\n" ..
postdata .. "\r\n\r\n")
data$, bytes, done = ReceiveData(1, #RECEIVEALL)
CloseConnection(1)
Print(data$ .. "\n" .. bytes)
but I would like to keep it simpler.