I'm working on sending data from a livecode (5.5.3) Windows app to a central web server that is running LiveCode Server. I'm just putting the solution together and for some reason I cannot get the server to extract any of the data the I'm sending up in the POST message. I've even run the server script as part of the app before sending it to the server and the local app is able to extract the values, but the server is not.
Here is the LiveCode app code that is placed in a button an a card in a Windows environment.
Code: Select all
on mouseUp global gACTsaverLocation local tActRequest, tBodySize, tRequestBody, tRequestHeader -- Build the NWAC Request Header put createActRequestHeader( "NWAC", "NO", "100") into tRequestHeader put tRequestHeader into tActRequest put URLEncode(tActRequest) into tActRequest -- Send the message to the ACTsaver Server set the httpHeaders to "Content-Type: application/x-www-form-urlencoded" -- ??????? post tActRequest to url "<server address>ACTsaver_server.lc" put it into myResult put URLDecode(myResult) into myResult -- can't connect to DB, code "*" sent byserver if myResult="*" then answer "DB error" exit to top end if answer myResult end mouseUp function createActRequestHeader tMsgType tMsgEncrypt tMsgSize local tActRequestHeader put "SAVER_Server=1.0"& "&" into tActRequestHeader -- Get the Date and Time put the seconds into tDateTime convert tDateTime to dateItems delete item 7 of tDateTime replace "," with "-" in tDateTime put "Date=" & tDateTime & "&" after tActRequestHeader put "Type="& tMsgType & "&" after tActRequestHeader put "Size=" & tMsgSize & "&" after tActRequestHeader if tMsgEncrypt is YES then put "Encrypt=SCR1" & "&" after tActRequestHeader else put "Encrypt=NONE" & "&" after tActRequestHeader end if put "Segmented=NO" & "&" after tActRequestHeader put "form_submitted=true" after tActRequestHeader put RETURN after tActRequestHeader return tActRequestHeader end createActRequestHeader
I initially tried to use the $_POST array, but could not get any data from the variables, so I'm using more of a brute force method.
The server is on a Windows Workstation with a WAMP server installed. LiveCode Server V5.0.2 for Windows.
Code: Select all
<?lc set the errorMode to "inline" ?> <h1>Test Post</h1> <?lc local tRequestType, tRequestSize, tRequestDate, tRequestVersion, tRequestEncrypt, tRequestSegmented local tRequest local tResponseMsg put $_POST_RAW into tRequestHeader ## Get the values out of the message set the itemdelimiter to "&" repeat for each item tVariablePair in tRequestHeader set the itemdelimiter to "=" put urlDecode(item 1 of tVariablePair) into tVariableKey put urlDecode(item 2 of tVariablePair) into tVariableValue switch tVariableKey case "Type" put tVariableValue into tRequestType break case "Size" put tVariableValue into tRequestSize break case "Date" put tVariableValue into tRequestDate break case "SAVER_Version" put tVariableValue into tRequestVersion break case "Encrypt" put tVariableValue into tRequestEncrypt break case "Sequenced" put tVariableValue into tRequestSequenced break default break end switch set the itemdelimiter to "&" end repeat put "Req Type = "& tRequestType & "Req Size = " & tRequestSize" into tResponseMsg ## put URLEncode(tResponseMsg) into tResponseMsg put tRequestHeader after tResponseMsg put tResponseMsg ?>
Req Type = Req Size =
So the $_POST_RAW value is returned, but the Type and Size have not been extracted from the message.
I must be missing something basic in how the server is using variables and processing data. This should work
I've also used the libURLFormData to pack the message in the app and get exactly the same results.