标签:
private function http_curl($url,$data=null){
//1.初始化,创建一个新cURL资源
$ch = curl_init();
//2.设置URL和相应的选项
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);
//curl_setopt($ch, CURLOPT_HEADER, 0);
if(!empty($data)){
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
}
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);//禁止curl资源直接输出
//3.抓取URL并把它传递给浏览器
$opt=curl_exec($ch);
//4.关闭cURL资源,并且释放系统资源
curl_close($ch);
return $opt;
}
标签:
原文地址:http://www.cnblogs.com/llforeverlove/p/5366415.html