Today when learning PHP encountered to call the Curl library function to access the specific URL string, you need to write a method to make the call, before the Linux system is also useful to the Curl command line tool to perform the acquisition of related resources, on the wiki found the following description:
In addition PHP manual for PHP client URL function link : http://php.net/manual/zh/function.curl-setopt.php
PHP supports the Libcurl library created by Daniel Stenberg, capable of connecting various servers and using various protocols . Libcurl currently supports protocols such as HTTP, HTTPS, FTP, Gopher, Telnet, dict, file, LDAP. Libcurl also supports HTTPS certificate, HTTP POST, HTTP PUT, FTP upload (also can be done via PHP FTP extension), HTTP based on form upload, proxy, cookies, username + password Authentication.
As you can see from the above introduction, the Curl library function is a client that connects to a server through a URL that supports a variety of protocols and certifications .
Use the Libcurl library function to enable a curl session between the client and the server .
The curl functions defined in PHP have the following:
CURL function ?Table of Contents ?
- Curl_close -Close CURL session
- Curl_copy_handle -Copy a curl handle and all of its options
- Curl_errno -Returns the last error code
- Curl_error -String that returns the last error of the current session
- Curl_escape -Encodes a given string using a URL
- Curl_exec -performing a CURL session
- Curl_file_create -Create a Curlfile object
- Curl_getinfo -Gets the information for a Curl connection resource handle
- Curl_init -Initializing a CURL session
- Curl_multi_add_handle -Add a separate curl handle to the Curl batch session
- Curl_multi_close -Closes a set of curl handles
- Curl_multi_errno -Returns the error code of the last Curl batch
- Curl_multi_exec -Child connection that runs the current CURL handle
- Curl_multi_getcontent -If Curlopt_returntransfer is set, returns the text stream of the obtained output
- Curl_multi_info_read -Gets the relevant transport information for the currently resolved Curl
- Curl_multi_init -Returns a new Curl batch handle
- Curl_multi_remove_handle -Removes a handle resource from a curl batch handle resource
- Curl_multi_select -Waiting for active connections in all Curl batches
- Curl_multi_setopt -Set an option for CURL parallel processing
- Curl_multi_strerror -Returns the error code for the string description
- Curl_pause -pauses and cancels a connection.
- Curl_reset -Resets all options for a libcurl session handle
- Curl_setopt_array -Bulk setup options for CURL transfer sessions
- curl_setopt -Set CURL transfer options
- Curl_share_close -Turn off the CURL shared handle
- Curl_share_errno -return The last share Curl error number
- Curl_share_init -Initializes a cURL shared handle.
- Curl_share_setopt -Sets options for the CURL shared handle.
- Curl_share_strerror -return string describing the given error code
- Curl_strerror -string description of the return error code
- Curl_unescape -Decodes a given URL-encoded string
- Curl_version -Get CURL version information
Here's a basic introduction to wikis:
CURL (/k?l/or/k?:l/[4]) is a computer software project providing A& Nbsp;library and Command-line tool for transferring data using Various protocols. The CURL project produces the Products,  libcurl and  CURL . It was first released in 1997. The name originally stood for ' See URL '. The original author and leads developer is the Swedish developer Daniel stenberg.[1]
libcurl[edit]
Libcurlis a freeclient-side URL Transfer Library,SupportingCookiesDICT,FtpFTPS,Gopher,HTTP(withHttp/2Support),HTTP POST,HTTP PUT, http proxy tunneling, https, imap, kerberos, ldap, pop3, RTSP, SCP, And smtp. The library supports The file URI scheme, sftp, Telnet, tftp, File transfer resume, FTP uploading, HTTP form-based upload, HTTPS certificates, LDAPS , proxies, and User-plus-password authentication.
The Libcurl library is portable. It builds and works identically on many platforms, includingAixAmigaOS,AndroidBeOS,BlackBerry Tablet OSandBlackBerry 10,[5]OpenVMS,Darwin,DosFreebsdHP-UX, hurd, iOS, irix, linux, macos, NetBSD, netware, openbsd, os/2, QNX Neutrino, risc os, solaris, symbian, tru64, ultrix, UnixWare, And windows.
The Libcurl library is Free, thread-safe and ipv6 compatible. bindings are available for More than 40 languages, Including c/c++, java, PHP and python.
The Libcurl library can support Axtls, gnutls, mbed TLS, NSS, qsossl on IBM i, Schannel on Windows, Secure Transporton MacOS and IOS, SSL/TLS through OpenSSL, and Wolfssl.
CURL[edit]
CURL is a command line tool for getting or sending files using URL syntax.
Since CURL uses libcurl, it supports a range of common Internet protocols, currently including HTTP, HTTPS, FTP, FTPS, SCP , SFTP, TFTP, LDAP, DAP, DICT, TELNET, FILE, IMAP, POP3, SMTP and RTSP (the last four-in versions newer than 7.20.0 O R 9 February 2010).
CURL supports https and Performs SSL certificate verification by default if a secure protocol is specified s Uch as HTTPS. When CURL connects to a remote server via HTTPS, it'll first obtain the Remote server certificate and check against its< Span class= "Apple-converted-space" > ca certificate store the Validity of the remote server to ensure the one the one it claims to be. Some CURL packages has bundled with CA certificate store file. There is few options to specify CA certificate such as--cacert and--capath. --cacert option can used to specify the location of the CA certificate store file. In the Windows platform, if a CA certificate file was not specified, CURL would look for a CA certificate file name "Curl-ca -bundle.crt "in the following order:
- The Directory where the CURL program is located.
- Current working directory.
- Windows system directory.
- Windows directory.
- Directories specified in the%PATH% environment variables. [6]
CURL would return an error message if the remote server is using a self-signed certificate, or if the remote server Certifi Cate is not signed by a CA listed in the CA cert file. -K or--insecure option can is used to skip certificate verification. Alternatively, if the remote server is trusted, the remote server CA certificate can be added to the CA certificate store File.
Examples of CURL use from command line[edit]
Basic use of curl involves simply typing Curl at the command line, followed by the URL of the the output to R Etrieve.
to retrieve the example.com homepage, type:
Curl www.example.com
CURL defaults to displaying the output it retrieves to the standard output specified on the system (usually the terminal w Indow). So running the command above would, on most systems, display the www.example.com source-code in the terminal window.
CURL can write the output it retrieves to a file with The-o flag, thus:
Curl-o example.html www.example.com
This would store the source code for www.example.com into a file named example.html. While retrieving output, CURL would display a progress bar showing how much of the output has downloaded. Note However this cURL does not show a progress bar when preparing to display the output in the terminal window, since a P Rogress bar is likely to interfere with the display of the output.
To download output to a file, the with the same name as on the system it originates from, use The-o flag, for example:
Curl-o www.example.com/example.html
If the server responds that the file (example.html) was moved to a different location (indicated with a location:header an D a 3XX response code), use THE-L flags, for example:
Curl-ol www.example.com/example.html
CURL can connect to a remote server via HTTPS protocol (return error message if a CA certificate file cannot is located)
Curl https://securesite.com/login.html
To specify a CA certificate file:
Curl--cacert C:\TEMP\CACERTS.CRT https://securesite.com/login.html
To skip Certificate verification:
Curl--insecure https://self-signed-cert.com/login.html
Curl offers many other features, including proxy support, user authentication, FTP upload, HTTP post, SSL connections, COO Kies, file transfer resume, and Metalink.
About Libcurl and CURL