Modules/cURL/curl perform: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{ModuleFunction|cURL}} Let cURL do his work now, by call this function. ==Syntax== <syntaxhighlight lang="lua"> curl_perform(curl handler[, table callbackfunctions]) </syntaxhighlight> ==Requ...")
 
No edit summary
Line 46: Line 46:
==See also==
==See also==
{{Modules/cURL/functions}}
{{Modules/cURL/functions}}
[[Category:Modules]]

Revision as of 15:40, 16 July 2011


Package-x-generic.png This function is provided by the external module cURL. You must install this module to use this function.

Let cURL do his work now, by call this function.

Syntax

curl_perform(curl handler[, table callbackfunctions])

Required arguments

  • curl The curl handler

Optional arguments

  • callbackfunctions A set with callback functions;
local callbacks = {
    writefunction = function(data)
        -- This is the actual return data from the call
    end,
    headerfunction = function(data)
        -- This is the return headers from the call. (the webserver you call sends those headers back)
    end
}

Returns

Returns a curl code, if the code is CURLE_OK then your good. Other wise pass this code to curl_strerror, and then you will know what is going on.

Example

curl = curl_init();
if not curl then
    outputDebugString("Can't connect to http://mtasa.com/ with cURL");
else
    curl_setopt(curl, CURLOPT_URL, curl_escape(curl, "http://mtasa.com/"));
    curl_perform(curl, {
        writefunction = function(html)
            -- Hell what should i do with html? :S
        end,
    });
    curl_close(curl);
end


See also