php curl post 提交封装

/**
* post提交方式
* urlPost = 提交内容
* url = 链接
*/

private function Post($curlPost,$url){
  $curl = curl_init();
  curl_setopt($curl, CURLOPT_URL, $url);
  curl_setopt($curl, CURLOPT_HEADER, false);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_NOBODY, true);
  curl_setopt($curl, CURLOPT_POST, true);
  curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
  $return_str = curl_exec($curl);
  curl_close($curl);
  return $return_str;
}

posted @ 2018-01-24 17:30  聂蓝  阅读(210)  评论(0编辑  收藏  举报