PHP CURL模拟GET及POST函数代码_PHP教程
程序员文章站
2024-02-06 22:37:40
...
复制代码 代码如下:
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 '
错误:
'.curl_error($curl);
}
curl_close($curl);
return $tmpInfo;
}
?>
上一篇: QT程序打包 - Inno Setup
推荐阅读
-
PHP CURL模拟GET及POST函数代码_PHP教程
-
PHP函数:stream_context_create()模拟POST/GET
-
PHP函数:stream_context_create()模拟POST/GET
-
PHP使用curl模拟post上传及接收文件的方法,
-
PHP实用函数手册:stream_context_create()模拟POST/GET
-
PHP使用curl模拟post上传及接收文件的方法,_PHP教程
-
PHP实用函数:stream_context_create模拟POST/GET
-
php fsockopen函数发送post,get请求获得网页内容(反防采集)_PHP教程
-
PHP CURL模拟GET及POST函数代码_php技巧
-
php使用curl可以get 模拟post