Table of Contents
- curl_close — Close a cURL session
- curl_copy_handle — Copy a cURL handle along with all of its preferences
- curl_errno — Return the last error number
- curl_error — Return a string containing the last error for the current session
- curl_escape — URL encodes the given string
- curl_exec — Perform a cURL session
- curl_getinfo — Get information regarding a specific transfer
- curl_init — Initialize a cURL session
- curl_multi_add_handle — Add a normal cURL handle to a cURL multi handle
- curl_multi_close — Remove all cURL handles from a multi handle
- curl_multi_errno — Return the last multi curl error number
- curl_multi_exec — Run the sub-connections of the current cURL handle
- curl_multi_getcontent — Return the content of a cURL handle if CURLOPT_RETURNTRANSFER is set
- curl_multi_info_read — Get information about the current transfers
- curl_multi_init — Returns a new cURL multi handle
- curl_multi_remove_handle — Remove a handle from a set of cURL handles
- curl_multi_select — Wait until reading or writing is possible for any cURL multi handle connection
- curl_multi_setopt — Set a cURL multi option
- curl_multi_strerror — Return string describing error code
- curl_pause — Pause and unpause a connection
- curl_reset — Reset all options of a libcurl session handle
- curl_setopt — Set an option for a cURL transfer
- curl_setopt_array — Set multiple options for a cURL transfer
- curl_share_close — Close a cURL share handle
- curl_share_errno — Return the last share curl error number
- curl_share_init — Initialize a cURL share handle
- curl_share_setopt — Set an option for a cURL share handle
- curl_share_strerror — Return string describing the given error code
- curl_strerror — Return string describing the given error code
- curl_unescape — Decodes the given URL encoded string
- curl_upkeep — Performs any connection upkeep checks
- curl_version — Gets cURL version information
Found A Problem?
+add a note
User Contributed Notes 10 notes
up
down
27
Mr.KTO ¶
17 years ago
Because if you don't - on Windows this will produce windows-error-report (Program terminated unexpectedly)Don't foget to curl_close($ch); Even if curl_errno($ch) != 0
up
down
6
helmizz at yahoo dot com ¶
10 years ago
You can add form input. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <body> <form method="post" action=""> <?phpfunction curl_test($setopt_content) if( foreach ( }This is sample script to use curl, Just input curl_setopt,
exp :
curlsetop[0] ==> name : CURLOPT_URL ; value : http://amazon.com
curlsetop[1] ==> name : CURLOPT_RETURNTRANSFER ; value : true
curlsetop[2] ==> name : CURLOPT_FOLLOWLOCATION ; value : true
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="">
<meta name="Author" content="Helmi Anwar">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<table>
<tr class="rowid_add">
<td>curl_setopt [0]</td>
<td>Name : <input type="text" size="50" name="setopt_name[]"></td>
<td>Value :<input type="text" size="50" name="setopt_value[]"></td>
</tr>
<tr class="rowid_add">
<td>curl_setopt [0]</td>
<td>Name : <input type="text" size="50" name="setopt_name[]"></td>
<td>Value :<input type="text" size="50" name="setopt_value[]"></td>
</tr>
<tr class="rowid_add">
<td>curl_setopt [0]</td>
<td>Name : <input type="text" size="50" name="setopt_name[]"></td>
<td>Value :<input type="text" size="50" name="setopt_value[]"></td>
</tr>
<tr>
<td><input type="submit" name="submit_yes" value="EXECUTE"></td>
</tr>
</table>
</form>
{
$ch = curl_init();
curl_setopt_array($ch, $setopt_content);
$result_data = curl_exec($ch);
curl_close($ch);
return $result_data;
}
{
{
$value_content=$_REQUEST['setopt_value'][$k];
$index_content =strtoupper($index_content);
eval('$index_content = '.$index_content.';');
//echo ($index_content);
if($index_content!='')
{
if(strtoupper($value_content)=='TRUE')
{$setopt_content[$index_content]=TRUE;}
elseif(strtoupper($value_content)=='FALSE')
{$setopt_content[$index_content]=FALSE;}
else
{$setopt_content[$index_content]=$value_content;}
}
}$info=curl_test($setopt_content);
<textarea name="result" rows="25" cols="100"><?php echo htmlspecialchars($info);?></textarea>
</body>
</html>
up
down
2
Anonymous ¶
3 years ago
Note, if you will ever need to get/set unique handle for Curl-object, you might need to use CURL_PRIVATE property for each instace
https://www.php.net/manual/en/function.curl-setopt.php
up
down
3
simon [at] vhostdirect [dot] co [dot] uk ¶
20 years ago
After reinstalling MS-VC7 and compiling OpenSSL to finally realise this was'nt nesscary. If your like me and like *Nix systems more than Windows then you'll most probly have similar problems. I came across this, on a simple google with the right keywords. http://www.tonyspencer.com/journal/00000037.htm I read thru that and found my mistake. Its just a small list of notes, I found them to be the best I've found on the subject and the most simplist. Dont forget to add a simple line like this into your scripts to get them working on Win32. <?php All the best and I hope this helps. Simon LightfootIt took me quite some to to figure out how to get Curl (with SSL), OpenSSL and PHP to play nicely together.
if($WINDIR) curl_setopt($curl, CURLOPT_CAINFO, "c:\\windows\\ca-bundle.crt");
?>
Last note: ca-bundle.crt file is located in the Curl download. I stored mine in the windows directory and apache/php can access it fine.
vHost Direct Limited
mikeb[at]xamo[dot]com ¶
20 years ago
A note of warning for PHP 5 users: if you try to fetch the CURLINFO_CONTENT_TYPE using curl_getinfo when there is a connect error, you will core dump PHP. I have informed the Curl team about this, so it will hopefully be fixed soon. Just make sure you check for an error before you look for this data.
up
down
1
killermonk at REMOVE dot killermonk dot com ¶
17 years ago
Make sure that you have 'button_name.x' and 'button_name.y' in the post fields. PHP names these fields 'button_name_x' and 'button_name_y', while ASP uses a dot. Also, as noted above, be sure to include the '__VIEWSTATE' input field in your post request.For anyone trying to use cURL to submit to an ASP/ASPX page that uses an image as the submit button.
up
down
Peter X. ¶
16 years ago
For example, the following code is likely to generate a memory limit error: <?php <?php while (!Although it has been noted that cURL outperforms both file_get_contents and fopen when it comes to getting a file over a HTTP link, the disadvantage of cURL is that it has no way of only reading a part of a page at a time.
$ch = curl_init("http://www.example.com/reallybigfile.tar.gz");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$output = curl_exec($ch);$fh = fopen("out.tar.gz", 'w');
fwrite($fh, $output);
fclose($fh);
?>
While this, on the other hand, wouldn't
$hostfile = fopen("http://www.example.com/reallybigfile.tar.gz", 'r');
$fh = fopen("out.tar.gz", 'w');
$output = fread($hostfile, 8192);
fwrite($fh, $output);
}fclose($hostfile);
fclose($fh);
?>
up
down
-3
alidrus at langkah dot com ¶
20 years ago
PHP Notice: Use of undefined constant CURLOPT_MUTE - assumed 'CURLOPT_MUTE' in .... If you wish tu silence the curl output, use the following instead: <?php <?phpIn recent versions of php, CURLOPT_MUTE has (probably) been deprecated. Any attempt of using curl_setopt() to set CURLOPT_MUTE will give you a warning like this:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
?>
And then,
$curl_output=curl_exec($ch);
?>
The output of the curl operation will be stored as a string in $curl_output while the operation remains totally silent.
up
down
-4
richardkmiller AT gmail ¶
18 years ago
Beware of any extra spaces in the URL. A trailing space in the URL caused my script to fail with the message "empty reply from server".
up
down
-3
ciaoandriana8 at gmail dot com ¶
3 years ago
You can add form input. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <body> <form method="post" action=""> <?phpfunction curl_test($setopt_content) if( foreach ( }This is sample script to use curl, Just input curl_setopt,
exp :
curlsetop[0] ==> name : CURLOPT_URL ; value : https://amzn.to/3njlWW6
curlsetop[1] ==> name : CURLOPT_RETURNTRANSFER ; value : true
curlsetop[2] ==> name : CURLOPT_FOLLOWLOCATION ; value : true
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="">
<meta name="Author" content="Helmi Anwar">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<table>
<tr class="rowid_add">
<td>curl_setopt [0]</td>
<td>Name : <input type="text" size="50" name="setopt_name[]"></td>
<td>Value :<input type="text" size="50" name="setopt_value[]"></td>
</tr>
<tr class="rowid_add">
<td>curl_setopt [0]</td>
<td>Name : <input type="text" size="50" name="setopt_name[]"></td>
<td>Value :<input type="text" size="50" name="setopt_value[]"></td>
</tr>
<tr class="rowid_add">
<td>curl_setopt [0]</td>
<td>Name : <input type="text" size="50" name="setopt_name[]"></td>
<td>Value :<input type="text" size="50" name="setopt_value[]"></td>
</tr>
<tr>
<td><input type="submit" name="submit_yes" value="EXECUTE"></td>
</tr>
</table>
</form>
{
$ch = curl_init();
curl_setopt_array($ch, $setopt_content);
$result_data = curl_exec($ch);
curl_close($ch);
return $result_data;
}
{
{
$value_content=$_REQUEST['setopt_value'][$k];
$index_content =strtoupper($index_content);
eval('$index_content = '.$index_content.';');
//echo ($index_content);
if($index_content!='')
{
if(strtoupper($value_content)=='TRUE')
{$setopt_content[$index_content]=TRUE;}
elseif(strtoupper($value_content)=='FALSE')
{$setopt_content[$index_content]=FALSE;}
else
{$setopt_content[$index_content]=$value_content;}
}
}$info=curl_test($setopt_content);
<textarea name="result" rows="25" cols="100"><?php echo htmlspecialchars($info);?></textarea>
</body>
</html>
+add a note