标签:
网络请求:
1 /** 2 * 发起HTTPS请求 3 */ 4 function curl_post($url,$data=null,$header=null,$post=0) 5 { 6 //初始化curl 7 $ch = curl_init(); 8 //参数设置 9 $res= curl_setopt ($ch, CURLOPT_URL,$url); 10 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 11 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 12 curl_setopt ($ch, CURLOPT_HEADER, 0); 13 curl_setopt($ch, CURLOPT_POST, $post); 14 if($post && !is_null($data)) 15 curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 16 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 17 if (!is_null($header)) 18 curl_setopt($ch,CURLOPT_HTTPHEADER,$header); 19 $result = curl_exec ($ch); 20 //连接失败 21 curl_close($ch); 22 return $result; 23 }
标签:
原文地址:http://www.cnblogs.com/--xiaoyao--/p/5504023.html