@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | 'scope' => $this->config['scope'], |
| 55 | 55 | 'state' => $this->config['state'] ?: Str::random(), |
| 56 | 56 | ]; |
| 57 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
| 57 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function getUserInfo() |
| 93 | 93 | { |
| 94 | - if($this->type == 'app'){//App登录 |
|
| 95 | - if(!isset($_REQUEST['access_token']) ){ |
|
| 94 | + if ($this->type == 'app') {//App登录 |
|
| 95 | + if (!isset($_REQUEST['access_token'])) { |
|
| 96 | 96 | throw new OAuthException("Facebook APP登录 需要传输access_token参数! "); |
| 97 | 97 | } |
| 98 | 98 | $this->token['access_token'] = $_REQUEST['access_token']; |
| 99 | - }else { |
|
| 99 | + } else { |
|
| 100 | 100 | $this->getToken(); |
| 101 | 101 | } |
| 102 | 102 | $fields = isset($this->config['fields']) ? $this->config['fields'] : 'id,name,gender,picture.width(400)'; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $method = strtoupper($method); |
| 117 | 117 | $request = [ |
| 118 | 118 | 'method' => $method, |
| 119 | - 'uri' => self::API_BASE . $api, |
|
| 119 | + 'uri' => self::API_BASE.$api, |
|
| 120 | 120 | ]; |
| 121 | 121 | |
| 122 | 122 | $data = $this->$method($request['uri'], $params); |
@@ -96,7 +96,7 @@ |
||
| 96 | 96 | throw new OAuthException("Facebook APP登录 需要传输access_token参数! "); |
| 97 | 97 | } |
| 98 | 98 | $this->token['access_token'] = $_REQUEST['access_token']; |
| 99 | - }else { |
|
| 99 | + } else { |
|
| 100 | 100 | $this->getToken(); |
| 101 | 101 | } |
| 102 | 102 | $fields = isset($this->config['fields']) ? $this->config['fields'] : 'id,name,gender,picture.width(400)'; |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | |
| 7 | 7 | use tinymeng\OAuth2\Exception\OAuthException; |
| 8 | 8 | |
| 9 | -class Encryptor{ |
|
| 9 | +class Encryptor { |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * 解密数据(微信小程序手机号) |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | protected static function init($gateway, $config) |
| 37 | 37 | { |
| 38 | - if(empty($config)){ |
|
| 38 | + if (empty($config)) { |
|
| 39 | 39 | throw new OAuthException("第三方登录 [$gateway] config配置不能为空"); |
| 40 | 40 | } |
| 41 | 41 | $baseConfig = [ |
@@ -45,14 +45,14 @@ discard block |
||
| 45 | 45 | 'scope' => '', |
| 46 | 46 | 'type' => '', |
| 47 | 47 | ]; |
| 48 | - if($gateway == 'weixin'){ |
|
| 48 | + if ($gateway == 'weixin') { |
|
| 49 | 49 | /** 兼容 tinymeng/oauth v1.0.0完美升级 */ |
| 50 | 50 | $gateway = 'wechat'; |
| 51 | 51 | } |
| 52 | 52 | $gateway = Str::uFirst($gateway); |
| 53 | - $class = __NAMESPACE__ . '\\Gateways\\' . $gateway; |
|
| 53 | + $class = __NAMESPACE__.'\\Gateways\\'.$gateway; |
|
| 54 | 54 | if (class_exists($class)) { |
| 55 | - $app = new $class(array_replace_recursive($baseConfig,$config)); |
|
| 55 | + $app = new $class(array_replace_recursive($baseConfig, $config)); |
|
| 56 | 56 | if ($app instanceof GatewayInterface) { |
| 57 | 57 | return $app; |
| 58 | 58 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | 'state' => $this->config['state'], |
| 31 | 31 | 'skip_confirm' => 1, |
| 32 | 32 | ]; |
| 33 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
| 33 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $data = json_decode($data, true); |
| 79 | 79 | |
| 80 | 80 | if (!isset($data['result']) || $data['result'] !== 'ok') { |
| 81 | - throw new OAuthException('获取小米用户信息失败:' . json_encode($data)); |
|
| 81 | + throw new OAuthException('获取小米用户信息失败:'.json_encode($data)); |
|
| 82 | 82 | } |
| 83 | 83 | return $data['data']; |
| 84 | 84 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | if (isset($data['access_token'])) { |
| 112 | 112 | return $data; |
| 113 | 113 | } |
| 114 | - throw new OAuthException('获取小米 access_token 出错:' . json_encode($data)); |
|
| 114 | + throw new OAuthException('获取小米 access_token 出错:'.json_encode($data)); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -109,7 +109,7 @@ |
||
| 109 | 109 | ]; |
| 110 | 110 | |
| 111 | 111 | $payload = $this->base64UrlEncode(json_encode($headers)) . '.' . |
| 112 | - $this->base64UrlEncode(json_encode($claims)); |
|
| 112 | + $this->base64UrlEncode(json_encode($claims)); |
|
| 113 | 113 | |
| 114 | 114 | openssl_sign($payload, $signature, $key, OPENSSL_ALGO_SHA256); |
| 115 | 115 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | 'response_mode' => 'form_post', |
| 29 | 29 | 'state' => $this->config['state'], |
| 30 | 30 | ]; |
| 31 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
| 31 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -108,12 +108,12 @@ discard block |
||
| 108 | 108 | 'sub' => $this->config['app_id'], |
| 109 | 109 | ]; |
| 110 | 110 | |
| 111 | - $payload = $this->base64UrlEncode(json_encode($headers)) . '.' . |
|
| 111 | + $payload = $this->base64UrlEncode(json_encode($headers)).'.'. |
|
| 112 | 112 | $this->base64UrlEncode(json_encode($claims)); |
| 113 | 113 | |
| 114 | 114 | openssl_sign($payload, $signature, $key, OPENSSL_ALGO_SHA256); |
| 115 | 115 | |
| 116 | - return $payload . '.' . $this->base64UrlEncode($signature); |
|
| 116 | + return $payload.'.'.$this->base64UrlEncode($signature); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -151,6 +151,6 @@ discard block |
||
| 151 | 151 | if (isset($data['access_token'])) { |
| 152 | 152 | return $data; |
| 153 | 153 | } |
| 154 | - throw new OAuthException('获取Apple access_token 出错:' . json_encode($data)); |
|
| 154 | + throw new OAuthException('获取Apple access_token 出错:'.json_encode($data)); |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | \ No newline at end of file |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | 'state' => $this->config['state'], |
| 31 | 31 | 'response_mode' => 'query', |
| 32 | 32 | ]; |
| 33 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
| 33 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -70,14 +70,14 @@ discard block |
||
| 70 | 70 | $this->getToken(); |
| 71 | 71 | |
| 72 | 72 | $headers = [ |
| 73 | - 'Authorization: Bearer ' . $this->token['access_token'], |
|
| 73 | + 'Authorization: Bearer '.$this->token['access_token'], |
|
| 74 | 74 | ]; |
| 75 | 75 | |
| 76 | 76 | $data = $this->get($this->UserInfoURL, [], $headers); |
| 77 | 77 | $data = json_decode($data, true); |
| 78 | 78 | |
| 79 | 79 | if (!isset($data['id'])) { |
| 80 | - throw new OAuthException('获取Microsoft用户信息失败:' . json_encode($data)); |
|
| 80 | + throw new OAuthException('获取Microsoft用户信息失败:'.json_encode($data)); |
|
| 81 | 81 | } |
| 82 | 82 | return $data; |
| 83 | 83 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | if (isset($data['access_token'])) { |
| 113 | 113 | return $data; |
| 114 | 114 | } |
| 115 | - throw new OAuthException('获取Microsoft access_token 出错:' . json_encode($data)); |
|
| 115 | + throw new OAuthException('获取Microsoft access_token 出错:'.json_encode($data)); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | try { |
| 124 | 124 | $accessToken = $accessToken ?? $this->token['access_token']; |
| 125 | 125 | $headers = [ |
| 126 | - 'Authorization: Bearer ' . $accessToken, |
|
| 126 | + 'Authorization: Bearer '.$accessToken, |
|
| 127 | 127 | ]; |
| 128 | 128 | $data = $this->get($this->UserInfoURL, [], $headers); |
| 129 | 129 | $data = json_decode($data, true); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | 'state' => $this->config['state'] ?: '', |
| 31 | 31 | 'prompt' => 'consent' |
| 32 | 32 | ]; |
| 33 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
| 33 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $response = json_decode($response, true); |
| 95 | 95 | |
| 96 | 96 | if (!isset($response['accessToken'])) { |
| 97 | - throw new OAuthException('获取钉钉 access_token 出错:' . json_encode($response)); |
|
| 97 | + throw new OAuthException('获取钉钉 access_token 出错:'.json_encode($response)); |
|
| 98 | 98 | } |
| 99 | 99 | return $response; |
| 100 | 100 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | 'state' => $this->config['state'], |
| 31 | 31 | 'access_type' => 'offline', |
| 32 | 32 | ]; |
| 33 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
| 33 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $data = json_decode($data, true); |
| 80 | 80 | |
| 81 | 81 | if (!isset($data['displayName'])) { |
| 82 | - throw new OAuthException('获取华为用户信息失败:' . json_encode($data)); |
|
| 82 | + throw new OAuthException('获取华为用户信息失败:'.json_encode($data)); |
|
| 83 | 83 | } |
| 84 | 84 | return $data; |
| 85 | 85 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | if (isset($data['access_token'])) { |
| 113 | 113 | return $data; |
| 114 | 114 | } |
| 115 | - throw new OAuthException('获取华为 access_token 出错:' . json_encode($data)); |
|
| 115 | + throw new OAuthException('获取华为 access_token 出错:'.json_encode($data)); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | 'scope' => $this->config['scope'] ?: 'user_info', |
| 30 | 30 | 'state' => $this->config['state'] ?: '', |
| 31 | 31 | ]; |
| 32 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
| 32 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $data = json_decode($data, true); |
| 79 | 79 | |
| 80 | 80 | if (!isset($data['result'])) { |
| 81 | - throw new OAuthException('获取快手用户信息失败:' . json_encode($data)); |
|
| 81 | + throw new OAuthException('获取快手用户信息失败:'.json_encode($data)); |
|
| 82 | 82 | } |
| 83 | 83 | return $data['result']; |
| 84 | 84 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $response = json_decode($response, true); |
| 100 | 100 | |
| 101 | 101 | if (!isset($response['access_token'])) { |
| 102 | - throw new OAuthException('获取快手 access_token 出错:' . json_encode($response)); |
|
| 102 | + throw new OAuthException('获取快手 access_token 出错:'.json_encode($response)); |
|
| 103 | 103 | } |
| 104 | 104 | return $response; |
| 105 | 105 | } |