@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | 'state' => $this->config['state'], |
| 45 | 45 | 'scope' => $this->config['scope'], |
| 46 | 46 | ]; |
| 47 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
| 47 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | 'open_id' => isset($result['uid']) ? $result['uid'] : '', |
| 62 | 62 | 'union_id'=> isset($result['aid']) ? $result['aid'] : '', |
| 63 | 63 | 'channel' => ConstCode::TYPE_BAIDU, |
| 64 | - 'nickname'=> $result['uname'] ?? $result['login_name'] ?? '', // 优先使用 uname |
|
| 64 | + 'nickname'=> $result['uname'] ?? $result['login_name'] ?? '', // 优先使用 uname |
|
| 65 | 65 | 'gender' => isset($result['sex']) ? (($result['sex'] == '男' ? 1 : ($result['sex'] == '女' ? 2 : 0))) : ConstCode::GENDER, |
| 66 | - 'avatar' => $result['portrait'] ?? '', // 百度返回的头像字段 |
|
| 66 | + 'avatar' => $result['portrait'] ?? '', // 百度返回的头像字段 |
|
| 67 | 67 | 'birthday'=> '', |
| 68 | 68 | 'access_token'=> $this->token['access_token'] ?? '', |
| 69 | 69 | 'native'=> $result, |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | $data = $this->get($this->UserInfoURL, [], $headers); |
| 88 | 88 | $data = json_decode($data, true); |
| 89 | 89 | |
| 90 | - if(!isset($data['uid'])) { |
|
| 91 | - throw new OAuthException("获取百度用户信息失败:" . ($data['error_description'] ?? '未知错误')); |
|
| 90 | + if (!isset($data['uid'])) { |
|
| 91 | + throw new OAuthException("获取百度用户信息失败:".($data['error_description'] ?? '未知错误')); |
|
| 92 | 92 | } |
| 93 | 93 | return $data; |
| 94 | 94 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @author: JiaMeng <[email protected]> |
| 113 | 113 | * Updater: |
| 114 | 114 | */ |
| 115 | - protected function getToken(){ |
|
| 115 | + protected function getToken() { |
|
| 116 | 116 | if (empty($this->token)) { |
| 117 | 117 | /** 验证state参数 */ |
| 118 | 118 | $this->CheckState(); |
@@ -121,8 +121,8 @@ discard block |
||
| 121 | 121 | $params = $this->accessTokenParams(); |
| 122 | 122 | |
| 123 | 123 | /** 获取access_token */ |
| 124 | - $this->AccessTokenURL = $this->AccessTokenURL . '?' . http_build_query($params); |
|
| 125 | - $token = $this->post($this->AccessTokenURL); |
|
| 124 | + $this->AccessTokenURL = $this->AccessTokenURL.'?'.http_build_query($params); |
|
| 125 | + $token = $this->post($this->AccessTokenURL); |
|
| 126 | 126 | /** 解析token值(子类实现此方法) */ |
| 127 | 127 | $this->token = $this->parseToken($token); |
| 128 | 128 | } |
@@ -162,8 +162,8 @@ discard block |
||
| 162 | 162 | 'client_secret' => $this->config['app_secret'], |
| 163 | 163 | ]; |
| 164 | 164 | |
| 165 | - $this->AccessTokenURL = static::API_BASE . 'oauth/2.0/token'; |
|
| 166 | - $token = $this->post($this->AccessTokenURL . '?' . http_build_query($params)); |
|
| 165 | + $this->AccessTokenURL = static::API_BASE.'oauth/2.0/token'; |
|
| 166 | + $token = $this->post($this->AccessTokenURL.'?'.http_build_query($params)); |
|
| 167 | 167 | $token = $this->parseToken($token); |
| 168 | 168 | |
| 169 | 169 | if (isset($token['access_token'])) { |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | { |
| 183 | 183 | try { |
| 184 | 184 | $accessToken = $accessToken ?? $this->token['access_token']; |
| 185 | - $headers = ['Authorization: Bearer ' . $accessToken]; |
|
| 185 | + $headers = ['Authorization: Bearer '.$accessToken]; |
|
| 186 | 186 | $data = $this->get($this->UserInfoURL, [], $headers); |
| 187 | 187 | $data = json_decode($data, true); |
| 188 | 188 | return isset($data['uid']); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | 'scope' => $this->config['scope'], |
| 35 | 35 | 'state' => $this->config['state'] ?: Str::random(), |
| 36 | 36 | ]; |
| 37 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
| 37 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | 'channel' => ConstCode::TYPE_LINE, |
| 61 | 61 | 'nickname' => $result['displayName'], |
| 62 | 62 | 'gender' => ConstCode::GENDER, //line不返回性别信息 |
| 63 | - 'avatar' => isset($result['pictureUrl']) ? $result['pictureUrl'] . '/large' : '', |
|
| 63 | + 'avatar' => isset($result['pictureUrl']) ? $result['pictureUrl'].'/large' : '', |
|
| 64 | 64 | 'native' => $result, |
| 65 | 65 | ]; |
| 66 | 66 | return $userInfo; |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | $method = strtoupper($method); |
| 95 | 95 | $request = [ |
| 96 | 96 | 'method' => $method, |
| 97 | - 'uri' => self::API_BASE . $api, |
|
| 97 | + 'uri' => self::API_BASE.$api, |
|
| 98 | 98 | ]; |
| 99 | 99 | |
| 100 | - $headers = ['Authorization' => $this->token['token_type'] . ' ' . $this->token['access_token']]; |
|
| 100 | + $headers = ['Authorization' => $this->token['token_type'].' '.$this->token['access_token']]; |
|
| 101 | 101 | |
| 102 | 102 | $data = $this->$method($request['uri'], $params, $headers); |
| 103 | 103 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | 'scope' => $this->config['scope'], |
| 56 | 56 | 'display' => $this->display, |
| 57 | 57 | ]; |
| 58 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
| 58 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | 'nickname'=> $result['nickname'], |
| 78 | 78 | 'gender' => isset($result['gender']) ? $this->getGender($result['gender']) : ConstCode::GENDER, |
| 79 | 79 | 'avatar' => $result['figureurl_qq_2'] ? $result['figureurl_qq_2'] : $result['figureurl_qq_1'], |
| 80 | - 'birthday'=> date('Y-m-d',strtotime($result['year'])), |
|
| 80 | + 'birthday'=> date('Y-m-d', strtotime($result['year'])), |
|
| 81 | 81 | 'native' => $result, |
| 82 | 82 | ]; |
| 83 | 83 | return $userInfo; |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function openid() |
| 114 | 114 | { |
| 115 | - if($this->type == 'app'){//App登录 |
|
| 116 | - if(!isset($_REQUEST['access_token'])){ |
|
| 115 | + if ($this->type == 'app') {//App登录 |
|
| 116 | + if (!isset($_REQUEST['access_token'])) { |
|
| 117 | 117 | throw new OAuthException("腾讯QQ,APP登录 需要传输access_token参数! "); |
| 118 | 118 | } |
| 119 | 119 | $this->token['access_token'] = $_REQUEST['access_token']; |
| 120 | - }else{ |
|
| 120 | + } else { |
|
| 121 | 121 | /** 获取token */ |
| 122 | 122 | $this->getToken(); |
| 123 | 123 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | if (isset($data['access_token'])) { |
| 144 | 144 | return $data; |
| 145 | 145 | } else { |
| 146 | - throw new OAuthException("获取腾讯QQ ACCESS_TOKEN 出错:" . $token); |
|
| 146 | + throw new OAuthException("获取腾讯QQ ACCESS_TOKEN 出错:".$token); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @return mixed|string |
| 155 | 155 | * @throws OAuthException |
| 156 | 156 | */ |
| 157 | - private function getOpenID(){ |
|
| 157 | + private function getOpenID() { |
|
| 158 | 158 | $query = [ |
| 159 | 159 | 'access_token' => $this->token['access_token'] |
| 160 | 160 | ]; |
@@ -163,12 +163,12 @@ discard block |
||
| 163 | 163 | $query['unionid'] = 1; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - $data = $this->get(self::API_BASE . 'oauth2.0/me',$query); |
|
| 167 | - $data = json_decode(trim(substr($data, 9), " );\n"), true); |
|
| 166 | + $data = $this->get(self::API_BASE.'oauth2.0/me', $query); |
|
| 167 | + $data = json_decode(trim(substr($data, 9), " );\n"), true); |
|
| 168 | 168 | if (isset($data['openid'])) { |
| 169 | 169 | return $data; |
| 170 | 170 | } else { |
| 171 | - throw new OAuthException("获取用户openid出错:" . $data['error_description']); |
|
| 171 | + throw new OAuthException("获取用户openid出错:".$data['error_description']); |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | * M代表男性,F代表女性 |
| 178 | 178 | * @param $gender |
| 179 | 179 | */ |
| 180 | - public function getGender($gender){ |
|
| 180 | + public function getGender($gender) { |
|
| 181 | 181 | return $gender == '男' ? ConstCode::GENDER_MAN : ConstCode::GENDER_WOMEN; |
| 182 | 182 | } |
| 183 | 183 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | 'scope' => $this->config['scope'], |
| 42 | 42 | 'state' => $this->config['state'], |
| 43 | 43 | ]; |
| 44 | - return self::AUTHORIZE_URL . '?' . http_build_query($params); |
|
| 44 | + return self::AUTHORIZE_URL.'?'.http_build_query($params); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | 'avatar' => $result['picture'], |
| 71 | 71 | 'native' => $result, |
| 72 | 72 | ); |
| 73 | - if(isset($result['email'])){ |
|
| 73 | + if (isset($result['email'])) { |
|
| 74 | 74 | $userInfo['email'] = $result['email']; |
| 75 | 75 | } |
| 76 | 76 | return $userInfo; |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function getUserInfo() |
| 83 | 83 | { |
| 84 | - if($this->type == 'app'){//App登录 |
|
| 85 | - if(!isset($_REQUEST['code']) ){ |
|
| 84 | + if ($this->type == 'app') {//App登录 |
|
| 85 | + if (!isset($_REQUEST['code'])) { |
|
| 86 | 86 | throw new OAuthException("Google APP登录 需要传输code参数! "); |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | $this->getToken(); |
| 90 | - $headers = ['Authorization : Bearer ' . $this->token['access_token']]; |
|
| 91 | - $data = $this->get(self::API_BASE . 'oauth2/v2/userinfo', '', $headers); |
|
| 90 | + $headers = ['Authorization : Bearer '.$this->token['access_token']]; |
|
| 91 | + $data = $this->get(self::API_BASE.'oauth2/v2/userinfo', '', $headers); |
|
| 92 | 92 | return json_decode($data, true); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $this->saveState(); |
| 29 | 29 | //登录参数 |
| 30 | 30 | $oauthToken = $this->call('oauth/request_token', ['oauth_callback' => $this->config['callback']], 'POST'); |
| 31 | - return self::API_BASE . 'oauth/authenticate?oauth_token=' . $oauthToken['oauth_token']; |
|
| 31 | + return self::API_BASE.'oauth/authenticate?oauth_token='.$oauthToken['oauth_token']; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | if (isset($this->token['oauth_token_secret'])) { |
| 71 | 71 | $this->tokenSecret = $this->token['oauth_token_secret']; |
| 72 | 72 | } else { |
| 73 | - throw new OAuthException("获取Twitter ACCESS_TOKEN 出错:" . json_encode($this->token)); |
|
| 73 | + throw new OAuthException("获取Twitter ACCESS_TOKEN 出错:".json_encode($this->token)); |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $method = strtoupper($method); |
| 91 | 91 | $request = [ |
| 92 | 92 | 'method' => $method, |
| 93 | - 'uri' => self::API_BASE . $api, |
|
| 93 | + 'uri' => self::API_BASE.$api, |
|
| 94 | 94 | ]; |
| 95 | 95 | $oauthParams = $this->getOAuthParams($params); |
| 96 | 96 | $oauthParams['oauth_signature'] = $this->signature($request, $oauthParams); |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | ksort($params); |
| 137 | 137 | $sign_str = Str::buildParams($params, true); |
| 138 | - $sign_str = $request['method'] . '&' . rawurlencode($request['uri']) . '&' . rawurlencode($sign_str); |
|
| 139 | - $sign_key = $this->config['app_secret'] . '&' . $this->tokenSecret; |
|
| 138 | + $sign_str = $request['method'].'&'.rawurlencode($request['uri']).'&'.rawurlencode($sign_str); |
|
| 139 | + $sign_key = $this->config['app_secret'].'&'.$this->tokenSecret; |
|
| 140 | 140 | |
| 141 | 141 | return rawurlencode(base64_encode(hash_hmac('sha1', $sign_str, $sign_key, true))); |
| 142 | 142 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | { |
| 152 | 152 | $return = 'OAuth '; |
| 153 | 153 | foreach ($params as $k => $param) { |
| 154 | - $return .= $k . '="' . $param . '", '; |
|
| 154 | + $return .= $k.'="'.$param.'", '; |
|
| 155 | 155 | } |
| 156 | 156 | return rtrim($return, ', '); |
| 157 | 157 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * 解析access_token方法请求后的返回值 |
| 173 | 173 | * @param string $token 获取access_token的方法的返回值 |
| 174 | 174 | */ |
| 175 | - protected function parseToken($token){ |
|
| 175 | + protected function parseToken($token) { |
|
| 176 | 176 | return $token; |
| 177 | 177 | } |
| 178 | 178 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | 'state' => $this->config['state'], |
| 32 | 32 | 'scope' => $this->config['scope'] ?: 'read_user', |
| 33 | 33 | ]; |
| 34 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
| 34 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | public function userInfo() |
@@ -53,12 +53,12 @@ discard block |
||
| 53 | 53 | public function getUserInfo() |
| 54 | 54 | { |
| 55 | 55 | $this->openid(); |
| 56 | - $headers = ['Authorization: Bearer ' . $this->token['access_token']]; |
|
| 57 | - $data = $this->get(static::API_BASE . $this->UserInfoURL, [], $headers); |
|
| 56 | + $headers = ['Authorization: Bearer '.$this->token['access_token']]; |
|
| 57 | + $data = $this->get(static::API_BASE.$this->UserInfoURL, [], $headers); |
|
| 58 | 58 | $data = json_decode($data, true); |
| 59 | 59 | |
| 60 | - if(!isset($data['id'])) { |
|
| 61 | - throw new OAuthException("获取GitLab用户信息失败:" . ($data['error_description'] ?? '未知错误')); |
|
| 60 | + if (!isset($data['id'])) { |
|
| 61 | + throw new OAuthException("获取GitLab用户信息失败:".($data['error_description'] ?? '未知错误')); |
|
| 62 | 62 | } |
| 63 | 63 | return $data; |
| 64 | 64 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | if (isset($data['access_token'])) { |
| 107 | 107 | return $data; |
| 108 | 108 | } |
| 109 | - throw new OAuthException("获取GitLab ACCESS_TOKEN出错:" . ($data['error_description'] ?? '未知错误')); |
|
| 109 | + throw new OAuthException("获取GitLab ACCESS_TOKEN出错:".($data['error_description'] ?? '未知错误')); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $this->AuthorizeURL = str_replace("alipay", "alipaydev", $this->AuthorizeURL); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
| 84 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -114,17 +114,17 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | $userInfo = [ |
| 116 | 116 | 'open_id' => $this->openid(), |
| 117 | - 'union_id' => $this->token['union_id']??'', |
|
| 117 | + 'union_id' => $this->token['union_id'] ?? '', |
|
| 118 | 118 | 'channel' => ConstCode::TYPE_ALIPAY, |
| 119 | 119 | 'nickname' => $result['nick_name'], |
| 120 | 120 | 'gender' => isset($result['gender']) ? $this->getGender($result['gender']) : ConstCode::GENDER, |
| 121 | 121 | 'avatar' => $result['avatar'], |
| 122 | 122 | // 拓展字段 |
| 123 | - 'access_token' => $this->token['access_token']??'', |
|
| 123 | + 'access_token' => $this->token['access_token'] ?? '', |
|
| 124 | 124 | 'user_id' => $this->token['user_id'], |
| 125 | 125 | 'native' => $result, |
| 126 | 126 | ]; |
| 127 | - $userInfo['type'] = ConstCode::getTypeConst($userInfo['channel'],$this->type); |
|
| 127 | + $userInfo['type'] = ConstCode::getTypeConst($userInfo['channel'], $this->type); |
|
| 128 | 128 | return $userInfo; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -137,12 +137,12 @@ discard block |
||
| 137 | 137 | */ |
| 138 | 138 | public function getUserInfo() |
| 139 | 139 | { |
| 140 | - if($this->type == 'app'){//App登录 |
|
| 141 | - if(!isset($_REQUEST['access_token']) ){ |
|
| 140 | + if ($this->type == 'app') {//App登录 |
|
| 141 | + if (!isset($_REQUEST['access_token'])) { |
|
| 142 | 142 | throw new OAuthException("AliPay APP登录 需要传输access_token参数! "); |
| 143 | 143 | } |
| 144 | 144 | $this->token['access_token'] = $_REQUEST['access_token']; |
| 145 | - }else { |
|
| 145 | + } else { |
|
| 146 | 146 | /** 获取token信息 */ |
| 147 | 147 | $this->getToken(); |
| 148 | 148 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | $data = $this->post(self::API_BASE, $params); |
| 162 | 162 | $data = mb_convert_encoding($data, 'utf-8', 'gbk'); |
| 163 | - $result = json_decode($data, true); |
|
| 163 | + $result = json_decode($data, true); |
|
| 164 | 164 | return $result['alipay_user_info_share_response']; |
| 165 | 165 | } |
| 166 | 166 | |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | throw new OAuthException('支付宝RSA密钥未配置'); |
| 238 | 238 | } |
| 239 | 239 | $rsa = str_replace([PHP_EOL, $header, $footer], '', $rsa); |
| 240 | - $rsaVal = $header . PHP_EOL . chunk_split($rsa, 64, PHP_EOL) . $footer; |
|
| 240 | + $rsaVal = $header.PHP_EOL.chunk_split($rsa, 64, PHP_EOL).$footer; |
|
| 241 | 241 | return $rsaVal; |
| 242 | 242 | } |
| 243 | 243 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | if (isset($data['alipay_system_oauth_token_response'])) { |
| 258 | 258 | $data = $data['alipay_system_oauth_token_response']; |
| 259 | - $data['openid'] = $data['open_id']??$data['user_id']; |
|
| 259 | + $data['openid'] = $data['open_id'] ?? $data['user_id']; |
|
| 260 | 260 | return $data; |
| 261 | 261 | } else { |
| 262 | 262 | throw new OAuthException("获取支付宝 ACCESS_TOKEN 出错:{$token}"); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | 'state' => $this->config['state'], |
| 39 | 39 | 'display' => $this->display, |
| 40 | 40 | ]; |
| 41 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
| 41 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -91,16 +91,16 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function getUserInfo() |
| 93 | 93 | { |
| 94 | - if($this->type == 'app'){//App登录 |
|
| 95 | - if(!isset($_REQUEST['access_token']) || !isset($_REQUEST['uid'])){ |
|
| 94 | + if ($this->type == 'app') {//App登录 |
|
| 95 | + if (!isset($_REQUEST['access_token']) || !isset($_REQUEST['uid'])) { |
|
| 96 | 96 | throw new OAuthException("Sina APP登录 需要传输access_token和uid参数! "); |
| 97 | 97 | } |
| 98 | 98 | $this->token['access_token'] = $_REQUEST['access_token']; |
| 99 | 99 | $this->token['openid'] = $_REQUEST['uid']; |
| 100 | - }else{ |
|
| 100 | + } else { |
|
| 101 | 101 | /** 获取参数 */ |
| 102 | 102 | $params = $this->accessTokenParams(); |
| 103 | - $this->AccessTokenURL = $this->AccessTokenURL. '?' . http_build_query($params);//get传参 |
|
| 103 | + $this->AccessTokenURL = $this->AccessTokenURL.'?'.http_build_query($params); //get传参 |
|
| 104 | 104 | $this->getToken(); |
| 105 | 105 | } |
| 106 | 106 | |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | $method = strtoupper($method); |
| 122 | 122 | |
| 123 | - if(isset($this->token['access_token'])){ |
|
| 123 | + if (isset($this->token['access_token'])) { |
|
| 124 | 124 | $params['access_token'] = $this->token['access_token']; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $data = $this->$method(self::API_BASE . $api, $params); |
|
| 127 | + $data = $this->$method(self::API_BASE.$api, $params); |
|
| 128 | 128 | return json_decode($data, true); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -165,8 +165,8 @@ discard block |
||
| 165 | 165 | * @param $data |
| 166 | 166 | * @return mixed |
| 167 | 167 | */ |
| 168 | - public function statusesShare($data){ |
|
| 169 | - return $this->call('statuses/share.json', json_encode($data),'POST'); |
|
| 168 | + public function statusesShare($data) { |
|
| 169 | + return $this->call('statuses/share.json', json_encode($data), 'POST'); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | 'scope' => $this->config['scope'], |
| 40 | 40 | 'state' => $this->config['state'] ?: Str::random(), |
| 41 | 41 | ]; |
| 42 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
| 42 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -76,13 +76,13 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function getUserInfo() |
| 78 | 78 | { |
| 79 | - if($this->type == 'app'){//App登录 |
|
| 80 | - if(!isset($_REQUEST['access_token']) ){ |
|
| 79 | + if ($this->type == 'app') {//App登录 |
|
| 80 | + if (!isset($_REQUEST['access_token'])) { |
|
| 81 | 81 | throw new OAuthException("Naver APP登录 需要传输access_token参数! "); |
| 82 | 82 | } |
| 83 | 83 | $this->token['token_type'] = 'Bearer'; |
| 84 | 84 | $this->token['access_token'] = $_REQUEST['access_token']; |
| 85 | - }else { |
|
| 85 | + } else { |
|
| 86 | 86 | $this->getToken(); |
| 87 | 87 | } |
| 88 | 88 | $data = $this->call('nid/me', $this->token, 'GET'); |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | $method = strtoupper($method); |
| 106 | 106 | $request = [ |
| 107 | 107 | 'method' => $method, |
| 108 | - 'uri' => self::API_BASE . $api, |
|
| 108 | + 'uri' => self::API_BASE.$api, |
|
| 109 | 109 | ]; |
| 110 | 110 | |
| 111 | - $headers = ['Authorization' => $this->token['token_type'] . ' ' . $this->token['access_token']]; |
|
| 111 | + $headers = ['Authorization' => $this->token['token_type'].' '.$this->token['access_token']]; |
|
| 112 | 112 | |
| 113 | 113 | $data = $this->$method($request['uri'], $params, $headers); |
| 114 | 114 | |