http_curl($url,'get') 这个方法没看到?谁有贴一个
function http_curl($url,$type='get',$res='json',$arr=''){
//1,初始化curl
$ch = curl_init();
//2,设置 curl的参数
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if ($type == 'post') {
curl_setopt($ch, CURLOPT_POST, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $arr);
}
//3,采集
$output = curl_exec($ch);
//4,关闭
curl_close($ch);
if ($res == 'json') {
if ( curl_errno($ch) ) {
return curl_error($ch);
}else{
return json_decode($output,true);
}
}
}