1. --!movie
  2. --!encoding=utf-8
  3.  
  4. global $
  5.  
  6. ----------------------------------------
  7. -- Send data as HTTP(S) POST request (synchronous or blocking mode)
  8. ----------------------------------------
  9. on startMovie
  10.     _player.debugPlaybackEnabled = 1
  11.  
  12.     -- libs
  13.     $.import("curl")
  14.  
  15.     -- get a CURL handle (xtra instance)
  16.     ch = $.curl.init()
  17.  
  18.     -- specify options
  19.     ch.setOption($.curl.CURLOPT.URL, "https://valentin.dasdeck.com/xtras/curl_xtra/.test/echo.php")
  20.  
  21.     -- data represented in property list (with string properties!), encoded using helper function
  22.     data = [:]
  23.     data["foo"] = "äöü"
  24.     data["bar"] = "hello world&#?"
  25.     ch.setOption($.curl.CURLOPT.POSTFIELDS, $.curl.httpBuildQuery(data))
  26.  
  27.     -- a) if you don't care about verifying SSL certificates for HTTPS
  28.     ch.setOption($.curl.CURLOPT.SSL_VERIFYPEER, 0)
  29.  
  30.     -- b) if you do care about verifying SSL certificates
  31.     -- ch.setOption($.curl.CURLOPT.CAINFO, _movie.path&"ca-certificates.crt")
  32.  
  33.     -- returnMode: 0=return error code (=default), 1=return data
  34.     res = ch.exec(1)
  35.  
  36.     if integerP(res) then
  37.         -- print error description to message window
  38.         put "ERROR:" && curl_error(res)
  39.     else
  40.         -- print result returned by server to message window
  41.         put "RESULT:" && res.readRawString(res.length)
  42.     end if
  43. end
  44.  
[raw code]