Result Type: string or CURLcode number
Definition: Performs the CURL operation for the given curl object, and (usually) returns the response as a string. If you supply a write callback to collect response data, the result will be the completion CURLcode value.
The curlhandle will previously have been initialised with
Curl_Init and had options set on it with
Example: Just getting the data
let ch = curl_init("http://cognito.co.nz/") let data = curl_exec(ch) syslog("data = " + data)
Example: Getting a result code as well. There are many ways a network request can fail, and it is useful to know why. While debugging, you can also check the log file for CURL errors.
property retval = "" on MyWriteCallback(someData) let retval = retval + someData // optionally return false to abort end on Load let ch = curl_init("http://cognito.co.nz") curl_setopt(ch, CURLOPT_FOLLOWLOCATION, 1) // by supplying a write callback, curl_exec will return // a curl result code instead of the retrieved data curl_setopt(ch, CURLOPT_WRITEFUNCTION, "MyWriteCallback") let errorCode = curl_exec(ch) syslog("CURL result = " + errorCode) syslog("data = " + retval) end
Availability: available within MWScript handlers.