public function http_curl($url,$type='get',$res='json',$arr=''){
/*
$url 请求的url
$type 请求类型
$res 返回数据类型
$arr post请求参数
*/
$ch=curl_init();
/*$url='https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxf71d53c65df41aab&secret=e31e44c35067fb75759f53eed1cb1b26'; */
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
if($type=='post'){
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$arr);
}
$output = curl_exec($ch);
curl_close($ch);
if($res=='json'){
return json_decode($output,true);
}
}