PHP to turn on the Curl function
Open in PHP.ini
Make sure the PHP extension directory has the Php_curl.dll class libraryLocate the directory where the extension library is located in Php.intDetermine if there is a php_curl.dll in the
Yesterday, in the project, someone is judging whether a video under YouTube can be played, write down the following code: $request _url= ' http://youtube.com/get_video_info?video_id= '.$vid. ' &el=vevo&fmt=18&asv=2&hd=1 '; $ch=Curl_init ();
First, write a simple crawl page function
Copy Code code as follows:
function Getsources ($URL, $User _agent= ', $Referer _url= ')//crawl a specified page
{
$URL page address that needs to be crawled
$User _agent need to return
In the development of CMS with PHP, to use the PHP Curl function, the default state, this function needs to open curl expansion, with the use of the host, can be opened through the php.ini file extension, the following methods:
1, open php.ini,
Dedicate a encapsulated curl function to make it easy to call
Copy Code code as follows:
Function Curl ($url, $ifpost = 0, $datafields = ', $cookiefile = ', $v = False) {
$header = Array ("Connection:keep-alive", "accept:text/html,
Currently, the most comprehensive CURL Chinese explanation shows that PHP learning should be well mastered. There are many parameters. Most of them are useful. If you have mastered it and regular expressions, you must be a collection expert.
First,
Yesterday when I used curl to write an api interface, I found that the Call to undefined function curl_init () error was prompted when running the curl function. From the error, the curl_init () function is not defined, later I learned that this
This article introduces the PHP curl_errno function described by the cURL function library error code.
Background:The game interface uses PHP cURL extension for request operations. However, the requested server often does not respond or times out
How does PHP enable the CURL function?
For example, let's test php. ini first.
Code
The Code is as follows:
$ Ch = curl_init ();Curl_setopt ($ ch, CURLOPT_URL, "http://www.111cn.net ");Curl_setopt ($ ch, CURLOPT_HEADER,
Curl (), file_get_contents (), snoopy.class.php these three remote page fetch or capture tools,
The snoopy.class.php is still invaded by the use of the same, because he is more efficient and does not require server-specific configuration support,
This article mainly introduces you to the PHP using the Curl function to send a POST request of some considerations, the text through the sample code and explained in detail, for everyone to learn or use PHP has a certain reference value, the need
The curl function in php 1. installation and configuration of curl:
Linux installation:
Http://php.net/manual/zh/curl.setup.php
Windows installation:
Enable:
Extension = php_curl.dll // note the dll file of the corresponding version.
2. curl usage
Currently, the most comprehensive CURL Chinese explanation shows that PHP learning should be well mastered. There are many parameters. Most of them are useful. If you have mastered it and regular expressions, you must be a collection expert. EN ""
wecenter-turn on the curl extension and let the server support the PHP Curl function (remote capture)
Curl (), file_get_contents (), snoopy.class.php these three remote page fetch or capture tools,
The snoopy.class.php is still invaded by the use
A demandRegistering a new user at Site A, the B site will also be registered at the same timeTwo ideasAt the same time as a site registration, call API interface implementation at the B site will also be registeredThree implementationsThe main code
Curl_close-closes a Curl session
curl_copy_handle-copies all the contents and parameters of a Curl connection resource
curl_errno-returns a numeric number containing the current session error message
curl_error-returns a string containing the
This article is on the interface problem in PHP (PHP interface is mainly using the Curl,curl function) for a detailed analysis of the introduction, the need for friends under the reference
Interface issuesthe most important thing about PHP calling
Curl is a transfer file tool using URL syntax that supports FTP, FTPS, HTTP htpps SCP SFTP TFTP TELNET DICT file and LDAP. Curl supports SSL certificates, HTTP POST, HTTP put, FTP uploads, Kerberos, upload based on htt format, proxy, cookie, user +
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.