The curl method of PHP function sharing is used to obtain data, simulate login, and POST data. Simply copy the code as follows: ********************** curl series **************** * ****** obtain data (including POST and HEADER) through curl directly) let's talk a little bit about code.
The code is as follows:
/********************** Curl series *************** ********/
// Obtain data directly through curl (including POST and HEADER)
/*
* $ Url: if it is not an array, http is used. if it is an array, https is used.
* $ Header: header file
* $ Post: array format submitted in post mode
* $ Cookies: 0 does not have a cookie by default, 1 is set, 2 is get
*/
Public function curl_allinfo ($ urls, $ header = FALSE, $ post = FALSE, $ cookies = 0 ){
$ Url = is_array ($ urls )? $ Urls ['0']: $ urls;
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
// Submit with header
If ($ header! = FALSE ){
Curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ header );
}
// Post submission method
If ($ post! = FALSE ){
Curl_setopt ($ ch, CURLOPT_POST, 1 );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ post );
}
If ($ cookies = 1 ){
Curl_setopt ($ ch, CURLOPT_COOKIEJAR, "cookiefile ");
} Else if ($ cookies = 2 ){
Curl_setopt ($ ch, CURLOPT_COOKIEFILE, "cookiefile ");
}
If (is_array ($ urls )){
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, false );
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, false );
}
$ Data = curl_exec ($ ch );
Curl_close ($ ch );
Return $ data;
}
The pipeline code is as follows: /********************** curl series *************** * ******* // Obtain data (including POST and HEADER) directly through curl )...