php curl方法

function CurlPost($url, $data)
{
  $curl = curl_init();
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
  curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
  curl_setopt($curl, CURLOPT_URL, $url);
  if(!empty($data))
  {
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  }
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  $result = curl_exec($curl);
  curl_close($curl);
  return $result;
}
function CurlGet($url)
{
  return CurlPost($url, "");
}

posted @ 2017-06-09 17:08  SingleShadow  阅读(175)  评论(0编辑  收藏  举报