公园网站建设,海外网络连接,网页设计制作基础,专注东莞微信网站设计废话就不多说 直接上代码#xff0c;亲测好用原生#xff1a;/*** curl发送htpp请求* 可以发送https,http,get方式,post方式,post数据发送*/public function dataRequest($url,$httpstrue,$methodget,$datanull){//初始化curl$ch curl_init($url);//字符串不直接输出#x…废话就不多说 直接上代码亲测好用原生/*** curl发送htpp请求* 可以发送https,http,get方式,post方式,post数据发送*/public function dataRequest($url,$httpstrue,$methodget,$datanull){//初始化curl$ch curl_init($url);//字符串不直接输出进行一个变量的存储curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//https请求if ($https true) {//确保https请求能够请求成功curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);}//post请求if ($method post) {curl_setopt($ch,CURLOPT_POST,true);curl_setopt($ch,CURLOPT_POSTFIELDS,$data);}//发送请求$str curl_exec($ch);$aStatus curl_getinfo($ch);//关闭连接curl_close($ch);if(intval($aStatus[http_code])200){return json_decode($str);}else{return false;}}使用方法$result $this -dataRequest(https://api.weixin.qq.com/cgi-bin/,true,get,);//数值转换$object json_decode( json_encode( $result),true);$data[access_token] $object[access_token];*文章为作者独立观点不代表上流阁立场本文由 江风成 授权 上流阁 发表并经上流阁编辑。转载此文章须经作者同意并请附上出处(上流阁)及本页链接。原文链接https://www.o6c.com/web/2017/02/14/901.html