PHPCURL simulates GET and POST function code. Copy the code as follows :? Phpfunctionvcurl ($ url, $ post, $ cookie, $ cookiejar, $ referer) {$ tmpInfo; $ cookiepathgetcwd ()... $ cookiejar; $ curlcurl _
The code is as follows:
Function vcurl ($ url, $ post = '', $ cookie ='', $ cookiejar = '', $ referer = ''){
$ TmpInfo = '';
$ Cookiepath = getcwd (). './'. $ cookiejar;
$ Curl = curl_init ();
Curl_setopt ($ curl, CURLOPT_URL, $ url );
Curl_setopt ($ curl, CURLOPT_USERAGENT, $ _ SERVER ['http _ USER_AGENT ']);
If ($ referer ){
Curl_setopt ($ curl, CURLOPT_REFERER, $ referer );
} Else {
Curl_setopt ($ curl, CURLOPT_AUTOREFERER, 1 );
}
If ($ post ){
Curl_setopt ($ curl, CURLOPT_POST, 1 );
Curl_setopt ($ curl, CURLOPT_POSTFIELDS, $ post );
}
If ($ cookie ){
Curl_setopt ($ curl, CURLOPT_COOKIE, $ cookie );
}
If ($ cookiejar ){
Curl_setopt ($ curl, CURLOPT_COOKIEJAR, $ cookiepath );
Curl_setopt ($ curl, CURLOPT_COOKIEFILE, $ cookiepath );
}
// Curl_setopt ($ curl, CURLOPT_FOLLOWLOCATION, 1 );
Curl_setopt ($ curl, CURLOPT_TIMEOUT, 100 );
Curl_setopt ($ curl, CURLOPT_HEADER, 0 );
Curl_setopt ($ curl, CURLOPT_RETURNTRANSFER, 1 );
$ TmpInfo = curl_exec ($ curl );
If (curl_errno ($ curl )){
Echo'
Error:
'. Curl_error ($ curl );
}
Curl_close ($ curl );
Return $ tmpInfo;
}
?>
The http://www.bkjia.com/PHPjc/321709.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/321709.htmlTechArticle code is as follows :? Php function vcurl ($ url, $ post = '', $ cookie ='', $ cookiejar = '', $ referer ='') {$ tmpInfo = ''; $ cookiepath = getcwd (). '. /'. $ cookiejar; $ curl = curl _...