The abridged list of Curl options

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.

 

Next chapter: Debugging Curl >>

Previous chapter: Your first Curl scripts

Jump to:

 

Home: Table of Contents

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar