function curl_post($postUrl,$data,$header = ""){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$postUrl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); if(substr($postUrl,0,5) == "https"){ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); } if(is_array($header) && count($header)>0){ curl_setopt($ch, CURLOPT_HTTPHEADER, $header); } $response = curl_exec($ch); curl_close($ch); return $response; } function curl_get($geturl){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$geturl); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); if(strpos($geturl,"https") !== false){ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); } $data = curl_exec($ch); curl_close($ch); return $data; }
PHP curl post get http or https
PHP curl post get http or https
- 栏目:
- 程序设计
- 发布时间:
- 2018-10-15
- 作者:
- luyugao,
- QQ:
- 10287093
- 热度:
- 5123℃
- 缩略图:
- 无
黄金分割