Hudzilla.org - the homepage of Paul Hudson
Contents > Networks > Curl Wish List | Report Bug | About Me ]

15.10.3     The abridged list of Curl options

This is NOT the latest copy of this book; click here for the latest version.

There are a large number of options available for curl_setopt() - far too many to cover here. However, of the full list, about half or so are used regularly and therefore deserve printing here. We will be looking at some of these in more depth shortly, but generally the whole list here is useful for the basic set of Curl operations:

If the 2nd parameter is...

3rd parameter should be...

CURLOPT_COOKIE

String containing the contents of the cookie data to be set in the HTTP header.

CURLOPT_COOKIEFILE

String containing the name of the file containing cookie data to be sent.

CURLOPT_CRLF

1 if you want Curl to convert Unix new lines to CR/LF new lines

CURLOPT_FAILONERROR

1 if you want Curl to fail silently if the HTTP code returned is equal to or larger than 300.

CURLOPT_FILE

String containing the filename where the output of your transfer should be placed. Default is straight to output (STDOUT).

CURLOPT_FOLLOWLOCATION

1 if you want Curl to follow all "Location: " header that the server sends as part of the HTTP header. You can limit the number of location headers to follow using CURLOPT_MAXREDIRS.

CURLOPT_FTPAPPEND

1 to have Curl append to the remote file instead of overwriting it.

CURLOPT_FTPLISTONLY

1 to list just the names of an FTP directory as opposed to more detailed information.

CURLOPT_HEADER

1 if you want the header to be included in the output. Usually for HTTP only.

CURLOPT_HTTPHEADER

An array of HTTP header fields to be set.

CURLOPT_INFILE

String containing the filename where the input of your transfer comes from.

CURLOPT_INFILESIZE

The size of the file being uploaded to a remote site.

CURLOPT_MAXREDIRS

The number of "Location:" headers Curl should follow before erroring out. This option is only appropriate if CURLOPT_FOLLOWLOCATION is used also.

CURLOPT_NOBODY

1 to tell Curl not to include the body part in the output. For HTTP(S) servers, this is equivalent to a HEAD request - only the headers will be returned.

CURLOPT_POST

1 if you want Curl to do a regular HTTP POST.

CURLOPT_POSTFIELDS

A string containing the data to post in the HTTP "POST" operation.

CURLOPT_REFERER

A string containing the "referer" header to be used in an HTTP request. This is only necessary if the remote server relies on this value.

CURLOPT_RESUME_FROM

A number equal to the offset, in bytes, that you want your transfer to start from.

CURLOPT_RETURNTRANSFER

1 if you want Curl to return the transfer data instead of printing it out directly.

CURLOPT_STDERR

A string containing the filename to write errors to instead of normal output.

CURLOPT_TIMEOUT

A number equal to the maximum time in seconds that Curl functions can take.

CURLOPT_UPLOAD

1 if you want PHP to prepare for a file upload.

CURLOPT_URL

String containing the URL you want Curl to fetch.

CURLOPT_USERPWD

A string formatted in the username:password manner, for Curl to give to the remote server if requested.

CURLOPT_USERAGENT

A string containing the "user-agent" header to be used in a HTTP request.

CURLOPT_VERBOSE

1 if you want Curl to give detailed reports about everything that is happening.

CURLOPT_WRITEHEADER

containing the filename to write the header part of the output into.

As you can see there are quite a few headers, and those are only the most popular - there is a large selection more available online at http://curl.haxx.se/libcurl/c/curl_easy_setopt.html.





<< 15.10.2 Your first Curl scripts: curl_init(), curl_setopt(), curl_exec(), curl_close()   15.10.4 Debugging Curl >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
Be the first to add a comment to this chapter!



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is nine plus nine?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow