@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | 'scope' => $this->config['scope'], |
44 | 44 | 'state' => $this->config['state'] ?: Str::random(), |
45 | 45 | ]; |
46 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
46 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | */ |
78 | 78 | public function getUserInfo() |
79 | 79 | { |
80 | - if($this->type == 'app'){//App登录 |
|
81 | - if(!isset($_REQUEST['access_token']) ){ |
|
80 | + if ($this->type == 'app') {//App登录 |
|
81 | + if (!isset($_REQUEST['access_token'])) { |
|
82 | 82 | throw new \Exception("Facebook APP登录 需要传输access_token参数! "); |
83 | 83 | } |
84 | 84 | $this->token['access_token'] = $_REQUEST['access_token']; |
85 | - }else { |
|
85 | + } else { |
|
86 | 86 | $this->getToken(); |
87 | 87 | } |
88 | 88 | $fields = isset($this->config['fields']) ? $this->config['fields'] : 'id,name,gender,picture.width(400)'; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $method = strtoupper($method); |
103 | 103 | $request = [ |
104 | 104 | 'method' => $method, |
105 | - 'uri' => self::API_BASE . $api, |
|
105 | + 'uri' => self::API_BASE.$api, |
|
106 | 106 | ]; |
107 | 107 | |
108 | 108 | $data = $this->$method($request['uri'], $params); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | 'scope' => $this->config['scope'], |
39 | 39 | 'state' => $this->config['state'] ?: Str::random(), |
40 | 40 | ]; |
41 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
41 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function getUserInfo() |
76 | 76 | { |
77 | - if($this->type == 'app'){//App登录 |
|
78 | - if(!isset($_REQUEST['access_token']) ){ |
|
77 | + if ($this->type == 'app') {//App登录 |
|
78 | + if (!isset($_REQUEST['access_token'])) { |
|
79 | 79 | throw new \Exception("Naver APP登录 需要传输access_token参数! "); |
80 | 80 | } |
81 | 81 | $this->token['token_type'] = 'Bearer'; |
82 | 82 | $this->token['access_token'] = $_REQUEST['access_token']; |
83 | - }else { |
|
83 | + } else { |
|
84 | 84 | $this->getToken(); |
85 | 85 | } |
86 | 86 | $data = $this->call('nid/me', $this->token, 'GET'); |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | $method = strtoupper($method); |
104 | 104 | $request = [ |
105 | 105 | 'method' => $method, |
106 | - 'uri' => self::API_BASE . $api, |
|
106 | + 'uri' => self::API_BASE.$api, |
|
107 | 107 | ]; |
108 | 108 | |
109 | - $headers = ['Authorization' => $this->token['token_type'] . ' ' . $this->token['access_token']]; |
|
109 | + $headers = ['Authorization' => $this->token['token_type'].' '.$this->token['access_token']]; |
|
110 | 110 | |
111 | 111 | $data = $this->$method($request['uri'], $params, $headers); |
112 | 112 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | 'state' => $this->config['state'], |
38 | 38 | 'display' => $this->display, |
39 | 39 | ]; |
40 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
40 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public function getUserInfo() |
90 | 90 | { |
91 | - if($this->type == 'app'){//App登录 |
|
92 | - if(!isset($_REQUEST['access_token']) || !isset($_REQUEST['uid'])){ |
|
91 | + if ($this->type == 'app') {//App登录 |
|
92 | + if (!isset($_REQUEST['access_token']) || !isset($_REQUEST['uid'])) { |
|
93 | 93 | throw new \Exception("Sina APP登录 需要传输access_token和uid参数! "); |
94 | 94 | } |
95 | 95 | $this->token['access_token'] = $_REQUEST['access_token']; |
96 | 96 | $this->token['openid'] = $_REQUEST['uid']; |
97 | - }else{ |
|
97 | + } else { |
|
98 | 98 | /** 获取参数 */ |
99 | 99 | $params = $this->accessTokenParams(); |
100 | - $this->AccessTokenURL = $this->AccessTokenURL. '?' . http_build_query($params);//get传参 |
|
100 | + $this->AccessTokenURL = $this->AccessTokenURL.'?'.http_build_query($params); //get传参 |
|
101 | 101 | $this->getToken(); |
102 | 102 | } |
103 | 103 | |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | { |
118 | 118 | $method = strtoupper($method); |
119 | 119 | |
120 | - if(isset($this->token['access_token'])){ |
|
120 | + if (isset($this->token['access_token'])) { |
|
121 | 121 | $params['access_token'] = $this->token['access_token']; |
122 | 122 | } |
123 | 123 | |
124 | - $data = $this->$method(self::API_BASE . $api, $params); |
|
124 | + $data = $this->$method(self::API_BASE.$api, $params); |
|
125 | 125 | return json_decode($data, true); |
126 | 126 | } |
127 | 127 | |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | * @param $data |
163 | 163 | * @return mixed |
164 | 164 | */ |
165 | - public function statusesShare($data){ |
|
166 | - return $this->call('statuses/share.json', json_encode($data),'POST'); |
|
165 | + public function statusesShare($data) { |
|
166 | + return $this->call('statuses/share.json', json_encode($data), 'POST'); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | if (in_array($k, $except)) { |
16 | 16 | continue; |
17 | 17 | } |
18 | - $param_str .= $k . '='; |
|
18 | + $param_str .= $k.'='; |
|
19 | 19 | $param_str .= $urlencode ? rawurlencode($v) : $v; |
20 | 20 | $param_str .= '&'; |
21 | 21 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | 'scope' => $this->config['scope'], |
34 | 34 | 'state' => $this->config['state'] ?: Str::random(), |
35 | 35 | ]; |
36 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
36 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | 'channel' => ConstCode::TYPE_LINE, |
58 | 58 | 'nickname' => $result['displayName'], |
59 | 59 | 'gender' => ConstCode::GENDER, //line不返回性别信息 |
60 | - 'avatar' => isset($result['pictureUrl']) ? $result['pictureUrl'] . '/large' : '', |
|
60 | + 'avatar' => isset($result['pictureUrl']) ? $result['pictureUrl'].'/large' : '', |
|
61 | 61 | ]; |
62 | 62 | return $userInfo; |
63 | 63 | } |
@@ -90,10 +90,10 @@ 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 | |
96 | - $headers = ['Authorization' => $this->token['token_type'] . ' ' . $this->token['access_token']]; |
|
96 | + $headers = ['Authorization' => $this->token['token_type'].' '.$this->token['access_token']]; |
|
97 | 97 | |
98 | 98 | $data = $this->$method($request['uri'], $params, $headers); |
99 | 99 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | protected static function init($gateway, $config) |
36 | 36 | { |
37 | - if(empty($config)){ |
|
37 | + if (empty($config)) { |
|
38 | 38 | throw new \Exception("第三方登录 [$gateway] config配置不能为空"); |
39 | 39 | } |
40 | 40 | $baseConfig = [ |
@@ -44,14 +44,14 @@ discard block |
||
44 | 44 | 'scope' => '', |
45 | 45 | 'type' => '', |
46 | 46 | ]; |
47 | - if($gateway == 'weixin'){ |
|
47 | + if ($gateway == 'weixin') { |
|
48 | 48 | /** 兼容 tinymeng/oauth v1.0.0完美升级 */ |
49 | 49 | $gateway = 'wechat'; |
50 | 50 | } |
51 | 51 | $gateway = Str::uFirst($gateway); |
52 | - $class = __NAMESPACE__ . '\\Gateways\\' . $gateway; |
|
52 | + $class = __NAMESPACE__.'\\Gateways\\'.$gateway; |
|
53 | 53 | if (class_exists($class)) { |
54 | - $app = new $class(array_replace_recursive($baseConfig,$config)); |
|
54 | + $app = new $class(array_replace_recursive($baseConfig, $config)); |
|
55 | 55 | if ($app instanceof GatewayInterface) { |
56 | 56 | return $app; |
57 | 57 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $this->saveState(); |
28 | 28 | //登录参数 |
29 | 29 | $oauthToken = $this->call('oauth/request_token', ['oauth_callback' => $this->config['callback']], 'POST'); |
30 | - return self::API_BASE . 'oauth/authenticate?oauth_token=' . $oauthToken['oauth_token']; |
|
30 | + return self::API_BASE.'oauth/authenticate?oauth_token='.$oauthToken['oauth_token']; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | if (isset($this->token['oauth_token_secret'])) { |
67 | 67 | $this->tokenSecret = $this->token['oauth_token_secret']; |
68 | 68 | } else { |
69 | - throw new \Exception("获取Twitter ACCESS_TOKEN 出错:" . json_encode($this->token)); |
|
69 | + throw new \Exception("获取Twitter ACCESS_TOKEN 出错:".json_encode($this->token)); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $method = strtoupper($method); |
87 | 87 | $request = [ |
88 | 88 | 'method' => $method, |
89 | - 'uri' => self::API_BASE . $api, |
|
89 | + 'uri' => self::API_BASE.$api, |
|
90 | 90 | ]; |
91 | 91 | $oauthParams = $this->getOAuthParams($params); |
92 | 92 | $oauthParams['oauth_signature'] = $this->signature($request, $oauthParams); |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | { |
132 | 132 | ksort($params); |
133 | 133 | $sign_str = Str::buildParams($params, true); |
134 | - $sign_str = $request['method'] . '&' . rawurlencode($request['uri']) . '&' . rawurlencode($sign_str); |
|
135 | - $sign_key = $this->config['app_secret'] . '&' . $this->tokenSecret; |
|
134 | + $sign_str = $request['method'].'&'.rawurlencode($request['uri']).'&'.rawurlencode($sign_str); |
|
135 | + $sign_key = $this->config['app_secret'].'&'.$this->tokenSecret; |
|
136 | 136 | |
137 | 137 | return rawurlencode(base64_encode(hash_hmac('sha1', $sign_str, $sign_key, true))); |
138 | 138 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | { |
148 | 148 | $return = 'OAuth '; |
149 | 149 | foreach ($params as $k => $param) { |
150 | - $return .= $k . '="' . $param . '", '; |
|
150 | + $return .= $k.'="'.$param.'", '; |
|
151 | 151 | } |
152 | 152 | return rtrim($return, ', '); |
153 | 153 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * 解析access_token方法请求后的返回值 |
169 | 169 | * @param string $token 获取access_token的方法的返回值 |
170 | 170 | */ |
171 | - protected function parseToken($token){ |
|
171 | + protected function parseToken($token) { |
|
172 | 172 | return $token; |
173 | 173 | } |
174 | 174 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | 'scope' => $this->config['scope'], |
41 | 41 | 'state' => $this->config['state'], |
42 | 42 | ]; |
43 | - return self::AUTHORIZE_URL . '?' . http_build_query($params); |
|
43 | + return self::AUTHORIZE_URL.'?'.http_build_query($params); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | 'gender' => isset($result['gender']) ? $this->getGender($result['gender']) : ConstCode::GENDER, |
69 | 69 | 'avatar' => $result['picture'], |
70 | 70 | ); |
71 | - if(isset($result['email'])){ |
|
71 | + if (isset($result['email'])) { |
|
72 | 72 | $userInfo['email'] = $result['email']; |
73 | 73 | } |
74 | 74 | return $userInfo; |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function getUserInfo() |
81 | 81 | { |
82 | - if($this->type == 'app'){//App登录 |
|
83 | - if(!isset($_REQUEST['code']) ){ |
|
82 | + if ($this->type == 'app') {//App登录 |
|
83 | + if (!isset($_REQUEST['code'])) { |
|
84 | 84 | throw new \Exception("Google APP登录 需要传输code参数! "); |
85 | 85 | } |
86 | 86 | } |
87 | 87 | $this->getToken(); |
88 | - $headers = ['Authorization : Bearer ' . $this->token['access_token']]; |
|
89 | - $data = $this->get(self::API_BASE . 'oauth2/v2/userinfo', '', $headers); |
|
88 | + $headers = ['Authorization : Bearer '.$this->token['access_token']]; |
|
89 | + $data = $this->get(self::API_BASE.'oauth2/v2/userinfo', '', $headers); |
|
90 | 90 | return json_decode($data, true); |
91 | 91 | } |
92 | 92 |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $this->saveState(); |
42 | 42 | |
43 | 43 | //获取代理链接 |
44 | - if(isset($this->config['proxy_url'])){ |
|
44 | + if (isset($this->config['proxy_url'])) { |
|
45 | 45 | return $this->getProxyURL(); |
46 | 46 | } |
47 | 47 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'scope' => $this->config['scope'], |
55 | 55 | 'state' => $this->config['state'], |
56 | 56 | ]; |
57 | - return $this->AuthorizeURL . '?' . http_build_query($params) . '#wechat_redirect'; |
|
57 | + return $this->AuthorizeURL.'?'.http_build_query($params).'#wechat_redirect'; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | 'state' => $this->config['state'], |
73 | 73 | 'redirect_uri' => $this->config['callback'], |
74 | 74 | ]; |
75 | - return $this->config['proxy_url'] . '?' . http_build_query($params); |
|
75 | + return $this->config['proxy_url'].'?'.http_build_query($params); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | 'union_id'=> $this->token['unionid'] ?? '', |
110 | 110 | 'access_token'=> $this->token['access_token'] ?? '', |
111 | 111 | 'channel' => ConstCode::TYPE_WECHAT, |
112 | - 'nickname'=> $result['nickname']??'', |
|
112 | + 'nickname'=> $result['nickname'] ?? '', |
|
113 | 113 | 'gender' => $result['sex'] ?? ConstCode::GENDER, |
114 | - 'avatar' => $result['headimgurl']??'', |
|
115 | - 'session_key' => $result['session_key']??'', |
|
114 | + 'avatar' => $result['headimgurl'] ?? '', |
|
115 | + 'session_key' => $result['session_key'] ?? '', |
|
116 | 116 | ]; |
117 | - $userInfo['type'] = ConstCode::getTypeConst($userInfo['channel'],$this->type); |
|
117 | + $userInfo['type'] = ConstCode::getTypeConst($userInfo['channel'], $this->type); |
|
118 | 118 | return $userInfo; |
119 | 119 | } |
120 | 120 | |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function getUserInfo() |
129 | 129 | { |
130 | - if($this->type == 'app'){//App登录 |
|
131 | - if(!isset($_REQUEST['access_token']) ){ |
|
130 | + if ($this->type == 'app') {//App登录 |
|
131 | + if (!isset($_REQUEST['access_token'])) { |
|
132 | 132 | throw new \Exception("Wechat APP登录 需要传输access_token参数! "); |
133 | 133 | } |
134 | 134 | $this->token['access_token'] = $_REQUEST['access_token']; |
135 | - }elseif ($this->type == 'applets'){ |
|
135 | + }elseif ($this->type == 'applets') { |
|
136 | 136 | //小程序 |
137 | 137 | return $this->applets(); |
138 | - }else { |
|
138 | + } else { |
|
139 | 139 | /** 获取token信息 */ |
140 | 140 | $this->getToken(); |
141 | 141 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | 'openid'=>$this->openid(), |
147 | 147 | 'lang'=>'zh_CN', |
148 | 148 | ]; |
149 | - $data = $this->get(self::API_BASE . 'userinfo', $params); |
|
149 | + $data = $this->get(self::API_BASE.'userinfo', $params); |
|
150 | 150 | return json_decode($data, true); |
151 | 151 | } |
152 | 152 | |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | * @return array|mixed|null |
155 | 155 | * @throws \Exception |
156 | 156 | */ |
157 | - public function applets(){ |
|
157 | + public function applets() { |
|
158 | 158 | /** 获取参数 */ |
159 | 159 | $params = $this->accessTokenParams(); |
160 | 160 | $params['js_code'] = $params['code']; |
161 | 161 | |
162 | 162 | /** 获取access_token */ |
163 | - $token = $this->get($this->jsCode2Session, $params); |
|
163 | + $token = $this->get($this->jsCode2Session, $params); |
|
164 | 164 | /** 解析token值(子类实现此方法) */ |
165 | 165 | $this->token = $this->parseToken($token); |
166 | 166 | return $this->token; |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $data = json_decode($token, true); |
217 | 217 | if (isset($data['access_token'])) { |
218 | 218 | return $data; |
219 | - }elseif (isset($data['session_key'])){ |
|
219 | + }elseif (isset($data['session_key'])) { |
|
220 | 220 | //小程序登录 |
221 | 221 | return $data; |
222 | 222 | } else { |