public function getCode(Request $request) { $config = [ 'client_id' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'redirect_uri' => '你的回调地址', 'state' => md5(uniqid()) ]; $url = 'https://openapi.baidu.com/oauth/2.0/authorize?response_type=code&client_id='. $config['client_id'].'&redirect_uri='. $config['redirect_uri'].'&scope=netdisk&display=mobile&qrcode=1&force_login=0&device_id=&state='.$config['state']; //生成二维码图片 $qrcode = QrCode::encoding('UTF-8')->size(300)->generate($url); $this->success('OK', [ 'qrcode' => base64_encode($qrcode), 'url' => $url ]); }
public function getAuth(Request $request) { $code = $request->input('code', ''); if(empty($code)){ exit(); } $config = [ 'client_id' => 'XXXXXXXXXXXXXXXXXXXXXXXX', 'SecretKey' => 'XXXXXXXXXXXXXXXXXXXXXXXX', 'redirect_uri' => '回调地址', ]; $url = 'https://openapi.baidu.com/oauth/2.0/token?grant_type=authorization_code&code='.$code.'&client_id='.$config['client_id'].'&client_secret='.$config['SecretKey'].'&redirect_uri=' . $config['redirect_uri'].'&state=get_list'; $result = $this->curl_get($url); $access_token = json_decode($result,true); }
以上就是PHP实现 百度网盘 获取access_token的详细内容,更多关于PHP实现 百度网盘 获取access_token的资料请关注九品源码其它相关文章!