封装一个curl的方法
/*
get请求
*/
function getcurl($url,$type=false,$data=''){
$ch = curl_init();
//设置选项,包括URL
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
if($type==true){
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
}
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output,true);
}