curl复制粘贴就可用

61 阅读1分钟
function request_post($url,$param = []){     
  $ch = curl_init();//初始化curl  
  curl_setopt($ch, CURLOPT_URL, $url);   
  curl_setopt($ch, CURLOPT_HEADER, 0);   
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
  curl_setopt($ch, CURLOPT_POST, 1);//post提交方式 
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 信任任何证书   
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($param));   
  $data = curl_exec($ch);//运行curl   
  curl_close($ch);  
  return $data;
}