PHP CURL模拟GET及POST函数代码
2010-04-25 00:00
676 查看
<?php 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 '<pre><b>错误:</b><br />'.curl_error($curl); } curl_close($curl); return $tmpInfo; } ?>
相关文章推荐
- PHP CURL模拟GET及POST函数代码
- PHP CURL模拟GET及POST函数代码
- PHP CURL模拟GET及POST函数
- php的curl函数模拟post、get数据提交,速度非常慢的处理办法
- HttpRequest模拟Post和Get提交代码
- php curl模拟post请求和提交多维数组的示例代码
- php 模拟POST|GET操作实现代码
- PHP Curl 函数,支持POST GET(修正2014-8-26)
- PHP curl get post 提交函数
- C#代码模拟http发送get和post请求
- PHP实用函数:stream_context_create()模拟POST/GET
- php curl实现get和post的代码
- php curl模拟post请求和提交多维数组的示例代码
- php的curl函数模拟post、get数据提交,速度非常慢的处理办法
- php中用socket模拟http中post或者get提交数据的示例代码
- php curl 发送GET,POST请求的函数
- PHP fsockopen介绍及fsockopen封装函数实现模拟GET或POST请求
- PHP实用函数手册:stream_context_create()模拟POST/GET