首页 > Web开发 > 详细

php curl

时间:2018-12-15 17:43:10      阅读:128      评论:0      收藏:0      [点我收藏+]

   /**
     * @param string $url
     * @param array $url_param
     * @param array $body_param
     * @param bool $is_post
     * @return mixed
     */

public
function sendHttpRequest($url,$url_param = null,$body_param = null,$is_post = true) { if($url_param){ $url_param = ‘?‘.http_build_query($url_param); } if($body_param){ $body_param = json_encode($body_param); } $ch = curl_init($url.$url_param); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if($is_post){ curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $body_param); } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); $data = curl_exec($ch); curl_close($ch); return $data; }

 

php curl

原文:https://www.cnblogs.com/mmmzh/p/10124052.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!