--!movie
--!encoding=utf-8
global $
----------------------------------------
-- Send data as HTTP(S) POST request (synchronous or blocking mode)
----------------------------------------
on startMovie
_player.debugPlaybackEnabled = 1
-- libs
$.import("curl")
-- get a CURL handle (xtra instance)
ch = $.curl.init()
-- specify options
ch.setOption($.curl.CURLOPT.URL, "https://valentin.dasdeck.com/xtras/curl_xtra/.test/echo.php")
-- data represented in property list (with string properties!), encoded using helper function
data = [:]
data["foo"] = "äöü"
data["bar"] = "hello world&#?"
ch.setOption($.curl.CURLOPT.POSTFIELDS, $.curl.httpBuildQuery(data))
-- a) if you don't care about verifying SSL certificates for HTTPS
ch.setOption($.curl.CURLOPT.SSL_VERIFYPEER, 0)
-- b) if you do care about verifying SSL certificates
-- ch.setOption($.curl.CURLOPT.CAINFO, _movie.path&"ca-certificates.crt")
-- returnMode: 0=return error code (=default), 1=return data
res = ch.exec(1)
if integerP(res) then
-- print error description to message window
put "ERROR:" && curl_error(res)
else
-- print result returned by server to message window
put "RESULT:" && res.readRawString(res.length)
end if
end