public function getAccessToken($data=[]){
$url = 'https://open.youzanyun.com/auth/token';
$data = [
'client_id' => 'xxxxxxxxxxxxxxx',
'client_secret' => '448bd8f34xxxxxxxxxxxxxxxx',
'authorize_type' => 'silent',
'grant_id' => '90768737',
'refresh' => false,
];
$data = json_encode($data);
$ch = curl_init();//初始化curl;
$header = [
'content-type: application/json',
];
if(!empty($header)){
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_HEADER, 0);//返回response头部信息
}
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); // 从证书中检查SSL加密算法是否存在
// POST数据
curl_setopt($ch, CURLOPT_POST, 1);
// 把post的变量加上
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
curl_close($ch);
$output = json_decode($output);
$accessToken = $output->data->access_token;
//dump($accessToken) ;
return $accessToken;
}