Phpcurl Option List (ultra-detailed)

Source: Internet
Author: User
Tags ftp commands random seed
This article provides a detailed analysis of the curl Option List in php. For more information, see

This article provides a detailed analysis of the curl Option List in php. For more information, see

Category 1:
For the following optional options, value should be set to a bool value:
Option
Optional value
Remarks

CURLOPT_AUTOREFERER
When Location: redirection is performed, the Referer: Information in the header is automatically set.
CURLOPT_BINARYTRANSFER
When CURLOPT_RETURNTRANSFER is enabled, the native (Raw) output is returned.
CURLOPT_COOKIESESSION
When curl is enabled, only one session cookie is passed, and the server space is ignored. By default, cURL returns all cookies to the server. Session cookie is a cookie used to determine whether a session on the server is valid.
CURLOPT_CRLF
When it is enabled, the Unix line break is converted into a carriage return line break.
CURLOPT_DNS_USE_GLOBAL_CACHE
When enabled, a global DNS cache is enabled. This option is thread-safe and enabled by default.
CURLOPT_FAILONERROR
The HTTP status code is displayed. The default behavior is to ignore the HTTP information whose number is less than or equal to 400.
CURLOPT_FILETIME
When enabled, the system tries to modify the information in the remote document. The result is returned through the CURLINFO_FILETIME option of the curl_getinfo () function. Curl_getinfo ().
CURLOPT_FOLLOWLOCATION
When enabled, the "Location:" returned by the server is put in the header and recursively returned to the server. You can use CURLOPT_MAXREDIRS to limit the number of recursive responses.
CURLOPT_FORBID_REUSE
After the interaction is completed, the connection is forcibly disconnected and cannot be reused.
CURLOPT_FRESH_CONNECT
Force a new connection to replace the connection in the cache.
CURLOPT_FTP_USE_EPRT
When FTP download is enabled, use the EPRT (or LPRT) command. If it is set to FALSE, disable EPRT and LPRT and use the PORT command only.
CURLOPT_FTP_USE_EPSV
When enabled, try the EPSV command before returning to PASV mode during FTP transmission. Disable the EPSV command when set to FALSE.
CURLOPT_FTPAPPEND
When enabled, append the data to the file instead of overwriting it.
CURLOPT_FTPASCII
The alias of CURLOPT_TRANSFERTEXT.
CURLOPT_FTPLISTONLY
Only the names of FTP directories are listed when enabled.
CURLOPT_HEADER
When enabled, the header file information is output as a data stream.
CURLINFO_HEADER_OUT
The request string of the tracking handle when it is enabled.
Available from PHP 5.1.3. CURLINFO _ prefix is intentional (intentional ).

CURLOPT_HTTPGET
When enabled, the HTTP method is set to GET. Because GET is set by default, it is used only when it is modified.
CURLOPT_HTTPPROXYTUNNEL
It is transmitted through the HTTP proxy when it is enabled.
CURLOPT_MUTE
When enabled, all modified parameters in the cURL function are restored to the default value.
CURLOPT_NETRC
After the connection is established, access ~ /. The netrc file obtains the user name and password to connect to the remote site.
CURLOPT_NOBODY
When enabled, the html body section is not output.
CURLOPT_NOPROGRESS
Disable the curl transmission progress bar when enabling. This item is enabled by default.
Note:
PHP automatically sets this option to TRUE, indicating the server space. This option should only be changed for debugging purposes.

CURLOPT_NOSIGNAL
When enabled, ignore all curl signals sent to php. This option is enabled by default during SAPI multi-thread transmission.
CURL 7.10 is added.

CURLOPT_POST
When it is enabled, a conventional POST request is sent. The type is application/x-www-form-urlencoded, just like form submission.
CURLOPT_PUT
When enabled, files can be sent over HTTP. Both CURLOPT_INFILE and CURLOPT_INFILESIZE must be set.
CURLOPT_RETURNTRANSFER
Return the information obtained by curl_exec () in the form of a file stream instead of directly outputting it.
CURLOPT_SSL_VERIFYPEER
After the cURL is disabled, it is terminated from the server for verification. Use the CURLOPT_CAINFO option to set the certificate. Use the CURLOPT_CAPATH option to set the certificate directory. If CURLOPT_SSL_VERIFYPEER (default value: 2) is enabled, set CURLOPT_SSL_VERIFYHOST to TRUE or FALSE.
The default value is TRUE since cURL 7.10. The installation is bound by default starting from cURL 7.10.

CURLOPT_TRANSFERTEXT
Use ASCII mode for FTP transmission after enabling. For LDAP, It retrieves plain text information rather than HTML. In Windows, STDOUT is not set to binary mode.
CURLOPT_UNRESTRICTED_AUTH
The username and password information is continuously appended to multiple locations in the header generated by CURLOPT_FOLLOWLOCATION, even if the domain name has changed.
CURLOPT_UPLOAD
Enable file upload.
CURLOPT_VERBOSE
When enabled, all information is reported and stored in STDERR or the specified CURLOPT_STDERR.

Category 2:
For the following optional options, value should be set to an integer value:
Option
Optional value
Remarks

CURLOPT_BUFFERSIZE
The size of the data read into the cache each time, but this value is not guaranteed to be filled every time.
Added to cURL 7.10.

CURLOPT_CLOSEPOLICY
CURLCLOSEPOLICY_LEAST_RECENTLY_USED is CURLCLOSEPOLICY_OLDEST. Three other CURLCLOSEPOLICY _ exist, but cURL is not supported yet.
CURLOPT_CONNECTTIMEOUT
The waiting time before the connection is initiated. If it is set to 0, it will be infinitely waiting.
CURLOPT_CONNECTTIMEOUT_MS
The waiting time for the connection attempt, in milliseconds. If it is set to 0, the system waits for no limit.
Added to cURL 7.16.2. Available from PHP 5.2.3.

CURLOPT_DNS_CACHE_TIMEOUT
Set the time for saving DNS information in the memory. The default value is 120 seconds.
CURLOPT_FTPSSLAUTH
FTP authentication method: CURLFTPAUTH_SSL (first try SSL), CURLFTPAUTH_TLS (first try TLS) or CURLFTPAUTH_DEFAULT (automatically determined by cURL ).
Added to cURL 7.12.2.

CURLOPT_HTTP_VERSION
CURL_HTTP_VERSION_NONE (default value: Let cURL determine which version to use), CURL_HTTP_VERSION_1_0 (HTTP/1.0 is mandatory) or CURL_HTTP_VERSION_1_1 (HTTP/1.1 is mandatory ).
CURLOPT_HTTPAUTH
The HTTP verification method used. Optional values: CURLAUTH_BASIC, CURLAUTH_DIGEST, CURLAUTH_GSSNEGOTIATE, CURLAUTH_NTLM, CURLAUTH_ANY, and CURLAUTH_ANYSAFE.
You can use the | bitfield (OR) operator to separate multiple values. cURL allows the server to select a value that supports the best.
CURLAUTH_ANY is equivalent to CURLAUTH_BASIC | CURLAUTH_DIGEST | CURLAUTH_GSSNEGOTIATE | CURLAUTH_NTLM.
CURLAUTH_ANYSAFE is equivalent to CURLAUTH_DIGEST | CURLAUTH_GSSNEGOTIATE | CURLAUTH_NTLM.
CURLOPT_INFILESIZE
Sets the size limit of the uploaded file, in bytes.
CURLOPT_LOW_SPEED_LIMIT
When the transmission speed is less than CURLOPT_LOW_SPEED_LIMIT (bytes/sec), PHP will determine whether to cancel the transmission because it is too slow Based on CURLOPT_LOW_SPEED_TIME.
CURLOPT_LOW_SPEED_TIME
When the transmission speed is less than CURLOPT_LOW_SPEED_LIMIT (bytes/sec), PHP will determine whether to cancel the transmission because it is too slow Based on CURLOPT_LOW_SPEED_TIME.
CURLOPT_MAXCONNECTS
The maximum number of connections allowed. If the maximum number is exceeded, CURLOPT_CLOSEPOLICY is used to determine which connections should be stopped.
CURLOPT_MAXREDIRS
Specifies the maximum number of HTTP redirects. This option is used with CURLOPT_FOLLOWLOCATION.
CURLOPT_PORT
Specifies the connection port. (Optional)
CURLOPT_PROTOCOLS
The bitfield of CURLPROTO _ * indicates. If enabled, the bitfield value limits the protocols that libcurl can use during transmission. This will allow you to support many protocols when compiling libcurl, but the restriction is only a subset of them that are allowed to be used. By default, libcurl uses all protocols supported by libcurl. See CURLOPT_REDIR_PROTOCOLS.
Available protocol options: CURLPROTO_HTTP, CURLPROTO_HTTPS, CURLPROTO_FTP, protocol, CURLPROTO_SCP, protocol, CURLPROTO_TELNET, CURLPROTO_LDAP, CURLPROTO_LDAPS, protocol, CURLPROTO_FILE, protocol, CURLPROTO_ALL
Added to cURL 7.19.4.

CURLOPT_PROXYAUTH
The authentication method of the HTTP proxy connection. Use the bitfield flag in CURLOPT_HTTPAUTH to set the corresponding options. For proxy verification, only CURLAUTH_BASIC and CURLAUTH_NTLM are currently supported.
Added to cURL 7.10.7.

CURLOPT_PROXYPORT
The port of the proxy server. You can also set the port in CURLOPT_PROXY.
CURLOPT_PROXYTYPE
CURLPROXY_HTTP (default) is CURLPROXY_SOCKS5.
Added to cURL 7.10.

CURLOPT_REDIR_PROTOCOLS
The bitfield value in CURLPROTO. If enabled, the bit field value limits the Protocol that the transmission thread can use when CURLOPT_FOLLOWLOCATION is enabled to follow a redirection. This will enable you to use the allowed protocol subset for the redirection duration transmission thread. The default libcurl will allow all protocols except FILE and SCP. This is different from any supported protocols in the 7.19.4 prerelease. For more information about protocol constants, see CURLOPT_PROTOCOLS.
Added to cURL 7.19.4.

CURLOPT_RESUME_FROM
A byte offset (used for resumable data transfer) is transmitted when transmission is resumed ).
CURLOPT_SSL_VERIFYHOST
1. check whether a common name exists in the server SSL certificate ). Note: The Common Name is generally the domain Name or sub-domain Name you want to apply for the SSL certificate ). 2. Check whether the public name exists and matches the provided host name.
CURLOPT_SSLVERSION
The SSL version used (2 or 3 ). By default, PHP detects this value by itself, although in some cases you need to manually set it.
CURLOPT_TIMECONDITION
If it has been edited after a certain time specified by CURLOPT_TIMEVALUE, CURL_TIMECOND_IFMODSINCE is used to return to the page. If it has Not been Modified and CURLOPT_HEADER is true, a header of "304 Not Modified" is returned, if CURLOPT_HEADER is false, use CURL_TIMECOND_IFUNMODSINCE. The default value is CURL_TIMECOND_IFUNMODSINCE.
CURLOPT_TIMEOUT
Sets the maximum number of seconds that cURL can be executed.
CURLOPT_TIMEOUT_MS
Sets the maximum number of milliseconds that cURL can execute.
Added to cURL 7.16.2. It can be used from PHP 5.2.3.

CURLOPT_TIMEVALUE
Set a timestamp used by CURLOPT_TIMECONDITION. By default, CURL_TIMECOND_IFMODSINCE is used.

Category 3:
For the optional parameters of the following options, value should be set to a string type value:
Option
Optional value
Remarks

CURLOPT_CAINFO
One file name stores one or more certificates used for server verification. This parameter is only valid when used with CURLOPT_SSL_VERIFYPEER. .
CURLOPT_CAPATH
A directory that stores multiple CA certificates. This option is used with CURLOPT_SSL_VERIFYPEER.
CURLOPT_COOKIE
Set the content of "Cookie:" in the HTTP request. Multiple cookies are separated by semicolons with a space (for example, "fruit = apple; color = red ").
CURLOPT_COOKIEFILE
The name of the file containing cookie data. The format of the cookie file can be Netscape, or only the HTTP header information is saved to the file.
CURLOPT_COOKIEJAR
The file that saves the cookie information after the connection ends.
CURLOPT_CUSTOMREQUEST
Use a custom request information instead of "GET" or "HEAD" as an HTTP request. This is for executing "DELETE" or other more concealed HTTP requests. Valid values include "GET", "POST", and "CONNECT. That is to say, do not enter the entire HTTP request here. For example, inputting "GET/index.html HTTP/1.0 \ r \ n" is incorrect.
Note:
Do not use this method before determining whether the server supports this custom request.


CURLOPT_EGDSOCKET
Similar to CURLOPT_RANDOM_FILE, except for one Entropy Gathering Daemon socket.
CURLOPT_ENCODING
The value of "Accept-Encoding:" in the HTTP request header. Supported encodings include "identity", "deflate", and "gzip ". If it is an empty string "", the request header will send all supported encoding types.
Added to cURL 7.10.

CURLOPT_FTPPORT
This value is used to obtain the IP address required by the FTP "POST" command. The "POST" Command tells the remote server to connect to the specified IP address. This string can be a plain text IP address, host name, a network interface Name (under UNIX), or just a '-' to use the default IP address.
CURLOPT_INTERFACE
Network sending interface name, which can be an Interface Name, IP address, or host name.
CURLOPT_KRB4LEVEL
KRB4 (Kerberos 4) security level. All values below are valid (in ascending order): "clear", "safe", "confidential", and "private ".. If the string does not match any of these, "private" is used ". If this option is set to NULL, KRB4 security authentication is disabled. Currently, KRB4 security authentication can only be used for FTP transmission.
CURLOPT_POSTFIELDS
All data is sent using the "POST" Operation in the HTTP protocol. To send a file, add the @ prefix to the file name and use the full path. You can use the urlencoded string like 'para1 = val1 & para2 = val2 &... 'or use an array with the field name as the key value and field data as the value. If the value is an array, the Content-Type header is set to multipart/form-data.
CURLOPT_PROXY
HTTP Proxy channel.
CURLOPT_PROXYUSERPWD
A string in the format of "[username]: [password]" used to connect to the proxy.
CURLOPT_RANDOM_FILE
A file name used to generate an SSL Random Seed.
CURLOPT_RANGE
In the form of "X-Y", where X and Y are optional to obtain the range of data, in bytes. The HTTP transport thread also supports several repeated items separated by commas, such as "X-Y, N-M ".
CURLOPT_REFERER
The content of "Referer:" in the HTTP request header.
CURLOPT_SSL_CIPHER_LIST
A list of SSL encryption algorithms. For example, both RC4-SHA and TLSv1 are available encrypted lists.
CURLOPT_SSLCERT
A file name that contains a PEM certificate.
CURLOPT_SSLCERTPASSWD
Use the password required by the CURLOPT_SSLCERT certificate.
CURLOPT_SSLCERTTYPE
Certificate type. Supported formats include "PEM" (default), "DER", and "ENG ".
Added to cURL 7.9.3.

CURLOPT_SSLENGINE
The encryption engine variable used to encrypt the SSL Private Key specified in CURLOPT_SSLKEY.
CURLOPT_SSLENGINE_DEFAULT
The variable used for asymmetric encryption.
CURLOPT_SSLKEY
The name of the file that contains the SSL private key.
CURLOPT_SSLKEYPASSWD
The password of the SSL Private Key specified in CURLOPT_SSLKEY.
Note:
Because this option contains sensitive password information, remember to ensure the security of this PHP script.

CURLOPT_SSLKEYTYPE
The encryption type of the private key specified in CURLOPT_SSLKEY. The supported key types are "PEM" (default), "DER", and "ENG ".
CURLOPT_URL
You can also set the URL address in the curl_init () function.
CURLOPT_USERAGENT
The HTTP request contains a "User-Agent:" header string.
CURLOPT_USERPWD
Pass the username and password required for a connection. The format is "[username]: [password]".


Category 4
For the optional parameters of the following options, value should be set as an array:
Option
Optional value
Remarks

CURLOPT_HTTP200ALIASES
200 response code array. Is the response in the array considered correct? Otherwise, it is considered wrong.
Added to cURL 7.10.3.

CURLOPT_HTTPHEADER
An array used to set HTTP header fields. Use an array in the following format: array ('content-type: text/plain ', 'content-length: 100 ')
CURLOPT_POSTQUOTE
A group of FTP commands executed on the server after the FTP request is executed.
CURLOPT_QUOTE
A group of FTP commands executed on the server prior to the FTP request.

For the optional parameters of the following options, value should be set as a stream Resource (for example, using fopen ()):
Option
Optional value

CURLOPT_FILE
Set the location of the output file. The value is a resource type. The default value is STDOUT (browser ).

CURLOPT_INFILE
The address of the file to be read when uploading the file. The value is a resource type.

CURLOPT_STDERR
Set an error output address. The value is a resource type that replaces the default STDERR.

CURLOPT_WRITEHEADER
Sets the address of the file to which the header is written. The value is a resource type.

For the optional parameters of the following options, value should be set as a callback function name:
Option
Optional value

CURLOPT_HEADERFUNCTION
Set a callback function. This function has two parameters: the first is the resource handle of cURL, and the second is the output header data. The output of header data must depend on this function to return the size of written data.

CURLOPT_PASSWDFUNCTION
Set a callback function with three parameters: the first is the resource handle of cURL, the second is a password prompt, and the third parameter is the maximum allowed password length. Returns the password value.

CURLOPT_PROGRESSFUNCTION
Set a callback function with three parameters: website space. The first is the resource handle of cURL, the second is a file descriptor resource, and the third is the length. Returns the contained data.

CURLOPT_READFUNCTION
Callback functions with two parameters. The first parameter is the session handle, and the second is the string of the HTTP response header information. Using this function, you can process the returned data. The returned value is the data size in bytes. 0 indicates the EOF signal.

CURLOPT_WRITEFUNCTION
Callback functions with two parameters. The first parameter is the session handle, and the second is the string of the HTTP response header information. With this callback function, the response header information is automatically processed. The response header is the entire string. Set the returned value to the exact length of the Written string. The transmission thread stops when an error occurs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.