Modules/cURL/curl perform: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 5: | Line 5: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
curlPerform(curl handler) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 17: | Line 17: | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
curl = | curl = curlInit(); | ||
if not curl then | if not curl then | ||
outputDebugString("Can't connect to http://mtasa.com/ with cURL"); | outputDebugString("Can't connect to http://mtasa.com/ with cURL"); | ||
else | else | ||
curlSetopt(curl, CURLOPT_URL, curlEscape(curl, "http://mtasa.com/")); | |||
result, data = | result, data = curlPerform(curl); | ||
if result == CURLE_OK then | if result == CURLE_OK then | ||
print(data) | print(data) | ||
end | end | ||
curlClose(curl); | |||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 11:11, 22 June 2014
| 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
curlPerform(curl handler)
Required arguments
- curl The curl handler
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. On a success call it will return the data as a second argument.
Example
curl = curlInit();
if not curl then
outputDebugString("Can't connect to http://mtasa.com/ with cURL");
else
curlSetopt(curl, CURLOPT_URL, curlEscape(curl, "http://mtasa.com/"));
result, data = curlPerform(curl);
if result == CURLE_OK then
print(data)
end
curlClose(curl);
end