//获得通讯录access_token
public function access_token(){
$wx = $this->enterpriseWx();
$url = $wx['access_token']."?corpid=".$wx['appid']."&corpsecret=".$wx['wxSecret'];
$date = $this->curl_get($url);
return $date;
}
//发送post请求
function curl_post($url,$data=array()){
$ch = curl_init();//创建curl请求
curl_setopt($ch, CURLOPT_URL,$url); //设置发送数据的网址
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); //设置有返回值,0,直接显示
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0); //禁用证书验证
curl_setopt($ch, CURLOPT_POST, 1);//post方法请求
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);//post请求发送的数据包
$data = curl_exec($ch);
curl_close($ch);
$data = json_decode($data,true); //将json数据转成数组
return $data;
}
//发送get请求
function curl_get($url){
$s = file_get_contents($url);
$s = json_decode($s, true);
return $s;
}
|