@@ -80,7 +80,7 @@ |
||
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'); |
@@ -94,7 +94,7 @@ |
||
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 | 100 | $this->AccessTokenURL = $this->AccessTokenURL. '?' . http_build_query($params);//get传参 |
@@ -52,18 +52,18 @@ |
||
52 | 52 | case self::TYPE_QQ: |
53 | 53 | if($type == 'app'){ |
54 | 54 | $typeConst = self::TYPE_QQ_APP;//qqApp |
55 | - }else{ |
|
55 | + } else{ |
|
56 | 56 | $typeConst = $channel; |
57 | 57 | } |
58 | 58 | break; |
59 | 59 | case self::TYPE_WECHAT: |
60 | 60 | if($type == 'app'){ |
61 | 61 | $typeConst = self::TYPE_WECHAT_APP;//微信App |
62 | - }else if($type == 'applets'){ |
|
62 | + } else if($type == 'applets'){ |
|
63 | 63 | $typeConst = self::TYPE_WECHAT_APPLETS;//微信小程序 |
64 | - }else if(Tool::isWeiXin()){ |
|
64 | + } else if(Tool::isWeiXin()){ |
|
65 | 65 | $typeConst = self::TYPE_WECHAT_MOBILE;//微信mobile |
66 | - }else{ |
|
66 | + } else{ |
|
67 | 67 | $typeConst = $channel; |
68 | 68 | } |
69 | 69 | break; |
@@ -108,7 +108,9 @@ discard block |
||
108 | 108 | ]; |
109 | 109 | $this->config = array_merge($_config, $config); |
110 | 110 | foreach($this->config as $key=>$val){ |
111 | - if(property_exists($this,$key)) $this->$key=$val; |
|
111 | + if(property_exists($this,$key)) { |
|
112 | + $this->$key=$val; |
|
113 | + } |
|
112 | 114 | } |
113 | 115 | $this->timestamp = time(); |
114 | 116 | } |
@@ -246,7 +248,7 @@ discard block |
||
246 | 248 | $token = $this->POST($this->AccessTokenURL, $params); |
247 | 249 | /** 解析token值(子类实现此方法) */ |
248 | 250 | $this->token = $this->parseToken($token); |
249 | - }else{ |
|
251 | + } else{ |
|
250 | 252 | return $this->token; |
251 | 253 | } |
252 | 254 | } |
@@ -19,11 +19,11 @@ |
||
19 | 19 | // var_dump($result['url']);die; |
20 | 20 | //重定向到第三方登录页 |
21 | 21 | header('Location: ' . $result['url']); |
22 | - }else{ |
|
22 | + } else{ |
|
23 | 23 | /** 登录回调 */ |
24 | 24 | $result = $this->callback($name); |
25 | 25 | var_dump($result);die; |
26 | 26 | } |
27 | -}catch(Exception $e){ |
|
27 | +} catch(Exception $e){ |
|
28 | 28 | echo 'Oauth登录失败!'.$e->getMessage(); |
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -33,7 +33,7 @@ |
||
33 | 33 | if($_GET['scope'] == 'snsapi_login'){ |
34 | 34 | //扫码登录 |
35 | 35 | $AuthorizeURL = $this->AuthorizeURL . '/connect/qrconnect'; |
36 | - }else{ |
|
36 | + } else{ |
|
37 | 37 | $AuthorizeURL = $this->AuthorizeURL . '/connect/oauth2/authorize'; |
38 | 38 | } |
39 | 39 |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | if($name == 'wechat'){ |
43 | 43 | if(!Tool::isMobile()){ |
44 | 44 | $this->config = $this->config['pc'];//微信pc扫码登录 |
45 | - }elseif(Tool::isWeiXin()){ |
|
45 | + } elseif(Tool::isWeiXin()){ |
|
46 | 46 | $this->config = $this->config['mobile'];//微信浏览器中打开 |
47 | - }else{ |
|
47 | + } else{ |
|
48 | 48 | echo '请使用微信打开!';exit();//手机浏览器打开 |
49 | 49 | } |
50 | 50 | } |
@@ -59,7 +59,9 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function login($name,$state=""){ |
61 | 61 | /** 获取配置 */ |
62 | - if($name == 'wx') $name = 'wechat'; |
|
62 | + if($name == 'wx') { |
|
63 | + $name = 'wechat'; |
|
64 | + } |
|
63 | 65 | $this->getConfig($name); |
64 | 66 | $this->config['state'] = $state; |
65 | 67 | |
@@ -94,7 +96,9 @@ discard block |
||
94 | 96 | public function callback($name) |
95 | 97 | { |
96 | 98 | /** 获取配置 */ |
97 | - if($name == 'wx') $name = 'wechat'; |
|
99 | + if($name == 'wx') { |
|
100 | + $name = 'wechat'; |
|
101 | + } |
|
98 | 102 | $this->getConfig($name); |
99 | 103 | |
100 | 104 | /** 初始化实例类 */ |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * https://developer.open-douyin.com/docs/resource/zh-CN/dop/develop/openapi/account-permission/douyin-default-get-permission-code |
76 | 76 | */ |
77 | 77 | return $this->AuthorizeSilenceURL . '?' . http_build_query($params); |
78 | - }else{ |
|
78 | + } else{ |
|
79 | 79 | return $this->AuthorizeURL . '?' . http_build_query($params); |
80 | 80 | } |
81 | 81 | } |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | throw new OAuthException("Douyin APP登录 需要传输access_token参数! "); |
139 | 139 | } |
140 | 140 | $this->token['access_token'] = $_REQUEST['access_token']; |
141 | - }elseif ($this->type == 'applets'){ |
|
141 | + } elseif ($this->type == 'applets'){ |
|
142 | 142 | //小程序 |
143 | 143 | return $this->applets(); |
144 | - }else { |
|
144 | + } else { |
|
145 | 145 | /** 获取token信息 */ |
146 | 146 | $this->getToken(); |
147 | 147 | } |
@@ -218,8 +218,12 @@ discard block |
||
218 | 218 | 'appid' => $this->config['app_id'], |
219 | 219 | 'secret' => $this->config['app_secret'], |
220 | 220 | ]; |
221 | - if(isset($_REQUEST['code'])) $params['code'] = $_REQUEST['code']; |
|
222 | - if(isset($_REQUEST['anonymous_code'])) $params['anonymous_code'] = $_REQUEST['anonymous_code']; |
|
221 | + if(isset($_REQUEST['code'])) { |
|
222 | + $params['code'] = $_REQUEST['code']; |
|
223 | + } |
|
224 | + if(isset($_REQUEST['anonymous_code'])) { |
|
225 | + $params['anonymous_code'] = $_REQUEST['anonymous_code']; |
|
226 | + } |
|
223 | 227 | |
224 | 228 | return $params; |
225 | 229 | } |
@@ -237,7 +241,7 @@ discard block |
||
237 | 241 | $data = json_decode($token, true); |
238 | 242 | if (isset($data['data']['access_token'])) { |
239 | 243 | return $data['data']; |
240 | - }elseif (isset($data['session_key'])){ |
|
244 | + } elseif (isset($data['session_key'])){ |
|
241 | 245 | //小程序登录 |
242 | 246 | return $data; |
243 | 247 | } else { |
@@ -117,7 +117,7 @@ |
||
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 | } |