[Long] Moving a REST request from Desktop to Server

Phil Davis revdev at pdslabs.net
Thu Mar 9 18:56:21 CET 2017


+1 Andre -

curl is definitely your friend for simple LC-server to other server 
communication. I maintain a server app that uses it to interact with the 
Vimeo server.

https://curl.haxx.se/docs/

Phil Davis


On 3/9/17 9:11 AM, Andre Garzia via use-livecode wrote:
> Hi,
>
> I would shell() to curl or a shell script and parse the result.
>
> om om
>
> On Tue, Mar 7, 2017 at 8:56 PM, Malte Brill via use-livecode <
> use-livecode at lists.runrev.com> wrote:
>
>> Hi all,
>>
>> I am trying to move a request I do from a desktop app to a liveCode server
>> script and am facing the problem that some of the stuff I use (most of it
>> libURL stuff) is not available on the server. Now I wonder how I could
>> translate it…
>>
>> Scenario is the following:
>> Problem is libURLLastRHHeaders() is unavailable on server and can not
>> easiely be copied from libURL
>> Anyone got an idea?
>>
>> local sCookieHeader
>>
>> on mouseUp
>>          local tURL,tUser,tPassWord,tCookie,tSubmitId,tsubmit,tJson,
>> tJsonArray
>>          local test
>>          try
>>                  set the httpHeaders to empty
>>                  put „aUser" into tUser
>>                  put „aPassword" into tPassWord
>>                  put "264812" into tSubmitID
>>                  put "Log+in" into tSubmit
>>                  get libURLFormData("userName", tUser,"password",
>> tPassword,"submit",tSubmit,"submitID",tSubmitId) — not available on
>> Server, but can be copied from libURL
>>                  post it to url "http://test.com/login.php"
>>                  _storeCookies libURLLastRHHeaders() — needed to
>> authenticate. libURLLastRHHeaders unavailable
>>                  set the httpHeaders to sCookieHeader
>>                  put fld "URL" into tURL
>>                  put URL tURL into tJson
>>          catch theErr
>>                  put theErr
>>          end try
>> end mouseUp
>>
>>
>> ## Parse header returned from a server and create a cookie header that
>> ## can be sent back: Cookie: cookie1;cookie2;cookie3;...
>> private command _StoreCookies pHeader
>>          local theCharNo,theCookieLine,theLineNo,theOffset
>>          put empty into sCookieHeader
>>          put 0 into theOffset
>>          repeat forever
>>                  put lineoffset("Set-Cookie:", pHeader, theOffset) into
>> theLineNo
>>                  if theLineNo > 0 then
>>                          add theOffset to theLineNo
>>                          put line theLineNo of pHeader into theCookieLine
>>                          delete word 1 of theCookieLine ## Set-Cookie:
>>                          put offset(";", theCookieLine) into theCharNo
>>                          if theCharNo > 0 then
>>                                  delete char theCharNo to -1 of
>> theCookieLine
>>                          end if
>>                          put theCookieLine & ";" after sCookieHeader
>>                          put theLineNo into theOffset
>>                  else
>>                          exit repeat
>>                  end if
>>          end repeat
>>          if the last char of sCookieHeader is ";" then
>>                  delete the last char of sCookieHeader
>>          end if
>>          if sCookieHeader is not empty then
>>                  put "Cookie: " before sCookieHeader
>>          end if
>>          return empty
>> end _StoreCookies
>>
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
>

-- 
Phil Davis




More information about the use-livecode mailing list