From 0e150e17b4df5d0e0e576d2253ebd8bcf1383557 Mon Sep 17 00:00:00 2001 From: panliang2019 <2540463097@qq.com> Date: Fri, 15 Jan 2021 19:51:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=91=BD=E5=90=8D=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++++---- src/Api/SocialiteApi.php | 12 ++++++------ src/Handle/JdOauth.php | 2 +- src/Handle/WeiXinOauth.php | 4 ++-- src/Helpers.php | 16 ++++++++-------- src/ServiceProvider.php | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index aa2def4..6cde512 100644 --- a/README.md +++ b/README.md @@ -207,7 +207,7 @@ class TestController */ public function authorization() { - $auth = new SocialiteAuth(Config::get('aouth.github')); + $auth = new SocialiteAuth(Config::get('oauth.github')); return $auth->redirect('github'); @@ -218,7 +218,7 @@ class TestController */ public function giteeCallback() { - $api = new SocialiteAuth(Config::get('aouth.github')); + $api = new SocialiteAuth(Config::get('oauth.github')); $user = $api->driver('github')->user(); @@ -286,14 +286,14 @@ class OauthController extends Controller public function redirect() { //return app('SocialiteAuth')->redirect('weibo'); - $api = new SocialiteAuth(config('services.aouth.github')); + $api = new SocialiteAuth(config('services.oauth.github')); return $api->redirect('github'); } public function auth() { // $api = app('SocialiteAuth')->driver('weibo'); //dd($api->user()) - $api = new SocialiteAuth(config('services.aouth.github')); + $api = new SocialiteAuth(config('services.oauth.github')); $user = $api->driver('github')->user(); dd($user); } diff --git a/src/Api/SocialiteApi.php b/src/Api/SocialiteApi.php index 51f2f69..a193fcd 100644 --- a/src/Api/SocialiteApi.php +++ b/src/Api/SocialiteApi.php @@ -97,20 +97,20 @@ public function getAccessToken(): string public function getUserInfo(): object { - $aouth = $this->getAccessToken(); + $oauth = $this->getAccessToken(); if ('weixin' == $this->deliver) { - return $this->api->getUserInfo(json_decode($aouth, true)); + return $this->api->getUserInfo(json_decode($oauth, true)); } /*elseif ('microsoft' == $this->deliver) { - $access_token = Helpers::getAccessToken($this->deliver, $aouth['$access_token']); + $access_token = Helpers::getAccessToken($this->deliver, $oauth['$access_token']); $userinfo = $this->api->getUserInfo($access_token); - $userinfo->unionid = $aouth['unionid']; - //$userinfo->openid=$aouth['sub']; + $userinfo->unionid = $oauth['unionid']; + //$userinfo->openid=$oauth['sub']; return $userinfo; } */ else { - $access_token = Helpers::getAccessToken($this->deliver, $aouth); + $access_token = Helpers::getAccessToken($this->deliver, $oauth); return $this->api->getUserInfo($access_token); } diff --git a/src/Handle/JdOauth.php b/src/Handle/JdOauth.php index c9d6329..d7d38b1 100644 --- a/src/Handle/JdOauth.php +++ b/src/Handle/JdOauth.php @@ -63,7 +63,7 @@ public function getAccessToken() return $res->access_token; } - public function getUserInfo($aouth) + public function getUserInfo($oauth) { $user = new \stdClass(); $user->openid = $this->openid; diff --git a/src/Handle/WeiXinOauth.php b/src/Handle/WeiXinOauth.php index 97eeacd..4ca5474 100644 --- a/src/Handle/WeiXinOauth.php +++ b/src/Handle/WeiXinOauth.php @@ -60,9 +60,9 @@ public function getAccessToken() ])->getBody()->getContents(); } - public function getUserInfo($aouth) + public function getUserInfo($oauth) { - $url = $this->userinfo_url.'='.$aouth['access_token'].'&openid='.$aouth['openid']; + $url = $this->userinfo_url.'='.$oauth['access_token'].'&openid='.$oauth['openid']; return json_decode($this->client->get($url)->getBody()->getContents()); } diff --git a/src/Helpers.php b/src/Helpers.php index a456d5d..f2be2eb 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -14,31 +14,31 @@ class Helpers { /** - * @param $aouth + * @param $oauth * @param string $key * * @return mixed */ - public static function getAccessToken($deiver, $aouth, $key = 'access_token') + public static function getAccessToken($deiver, $oauth, $key = 'access_token') { switch ($deiver) { case 'github': - $params = explode('=', $aouth); + $params = explode('=', $oauth); $access_token = $params[1]; $access_token = explode('&', $access_token); $access_token = $access_token[0]; return $access_token; break; case 'gitlab': - $aouth = json_decode($aouth, true); - return 'Bearer '.$aouth[$key]; + $oauth = json_decode($oauth, true); + return 'Bearer '.$oauth[$key]; break; case 'gitee': - $aouth = json_decode($aouth, true); - return $aouth[$key]; + $oauth = json_decode($oauth, true); + return $oauth[$key]; break; default: - return $aouth; + return $oauth; break; } } diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 68fab18..0838aa5 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -22,7 +22,7 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider public function register() { $this->app->singleton(SocialiteAuth::class, function ($app) { - return new SocialiteAuth(config('services.aouth')); + return new SocialiteAuth(config('services.$oauth')); }); $this->app->alias(SocialiteAuth::class, 'SocialiteAuth');