Passed
Push — master ( 80d84f...b77c15 )
by ma
01:46
created
example/oauth2.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 /**
6 6
  *
7 7
  */
8
-class oauth2{
8
+class oauth2 {
9 9
 
10 10
     /**
11 11
      * 全部配置文件
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     /**
27 27
      * @param $conf
28 28
      */
29
-    public function __construct($conf){
29
+    public function __construct($conf) {
30 30
         $this->configAll = $conf;
31 31
     }
32 32
 
@@ -37,15 +37,15 @@  discard block
 block discarded – undo
37 37
      * Updater:
38 38
      * @param $name
39 39
      */
40
-    public function getConfig($name){
41
-        $this->config = $this->configAll[$name]??[];
42
-        if($name == 'wechat'){
43
-            if(!Tool::isMobile()){
44
-                $this->config = $this->config['pc'];//微信pc扫码登录
45
-            }elseif(Tool::isWeiXin()){
46
-                $this->config = $this->config['mobile'];//微信浏览器中打开
47
-            }else{
48
-                echo '请使用微信打开!';exit();//手机浏览器打开
40
+    public function getConfig($name) {
41
+        $this->config = $this->configAll[$name] ?? [];
42
+        if ($name == 'wechat') {
43
+            if (!Tool::isMobile()) {
44
+                $this->config = $this->config['pc']; //微信pc扫码登录
45
+            }elseif (Tool::isWeiXin()) {
46
+                $this->config = $this->config['mobile']; //微信浏览器中打开
47
+            } else {
48
+                echo '请使用微信打开!'; exit(); //手机浏览器打开
49 49
             }
50 50
         }
51 51
         //可以设置代理服务器,一般用于调试国外平台
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
      * Author: JiaMeng <[email protected]>
58 58
      * Updater:
59 59
      */
60
-    public function login($name,$state=""){
60
+    public function login($name, $state = "") {
61 61
         /** 获取配置 */
62
-        if($name == 'wx') $name = 'wechat';
62
+        if ($name == 'wx') $name = 'wechat';
63 63
         $this->getConfig($name);
64 64
         $this->config['state'] = $state;
65 65
 
66 66
         /** 初始化实例类 */
67 67
         $oauth = OAuth::$name($this->config);
68
-        if(Tool::isMobile() || Tool::isWeiXin()){
68
+        if (Tool::isMobile() || Tool::isWeiXin()) {
69 69
             /**
70 70
              * 对于微博,如果登录界面要适用于手机,则需要设定->setDisplay('mobile')
71 71
              * 对于微信,如果是公众号登录,则需要设定->setDisplay('mobile'),否则是WEB网站扫码登录
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     public function callback($name)
95 95
     {
96 96
         /** 获取配置 */
97
-        if($name == 'wx') $name = 'wechat';
97
+        if ($name == 'wx') $name = 'wechat';
98 98
         $this->getConfig($name);
99 99
 
100 100
         /** 初始化实例类 */
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         /** 初始化实例类 */
Please login to merge, or discard this patch.
src/Gateways/Gitee.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
             'state'         => $this->config['state'],
35 35
             'scope'         => $this->config['scope'],
36 36
         ];
37
-        return $this->AuthorizeURL . '?' . http_build_query($params);
37
+        return $this->AuthorizeURL.'?'.http_build_query($params);
38 38
     }
39 39
 
40 40
     /**
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         $params = [
74 74
             'access_token'=>$this->token['access_token'],
75 75
         ];
76
-        $data = $this->get($this->UserInfoURL,$params);
76
+        $data = $this->get($this->UserInfoURL, $params);
77 77
         return json_decode($data, true);
78 78
     }
79 79
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     /**
92 92
      * Description:  获取AccessToken
93 93
      */
94
-    protected function getToken(){
94
+    protected function getToken() {
95 95
         if (empty($this->token)) {
96 96
             /** 验证state参数 */
97 97
             $this->CheckState();
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
             $params = $this->accessTokenParams();
101 101
 
102 102
             /** 获取access_token */
103
-            $this->AccessTokenURL = $this->AccessTokenURL . '?' . http_build_query($params);
104
-            $token =  $this->post($this->AccessTokenURL);
103
+            $this->AccessTokenURL = $this->AccessTokenURL.'?'.http_build_query($params);
104
+            $token = $this->post($this->AccessTokenURL);
105 105
             /** 解析token值(子类实现此方法) */
106 106
             $this->token = $this->parseToken($token);
107 107
         }
Please login to merge, or discard this patch.
src/Gateways/Douyin.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -22,21 +22,21 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class Douyin extends Gateway
24 24
 {
25
-    protected $ApiBase            = 'https://open.douyin.com';
25
+    protected $ApiBase = 'https://open.douyin.com';
26 26
     protected $AuthorizeURL   = 'https://open.douyin.com/platform/oauth/connect/';
27
-    protected $AuthorizeSilenceURL   = 'https://open.douyin.com/oauth/authorize/v2/';//抖音静默授权
27
+    protected $AuthorizeSilenceURL = 'https://open.douyin.com/oauth/authorize/v2/'; //抖音静默授权
28 28
     protected $AccessTokenURL = 'oauth/access_token/';
29 29
     protected $UserInfoURL = 'oauth/userinfo/';
30 30
 
31 31
     protected $jsCode2Session = 'https://minigame.zijieapi.com/mgplatform/api/apps/jscode2session';
32 32
 
33 33
     protected $API_BASE_ARRAY = [
34
-        'douyin'=>'https://open.douyin.com/',//抖音
35
-        'toutiao'=>'https://open.snssdk.com/',//头条
36
-        'xigua'=>'https://open-api.ixigua.com/',//西瓜
34
+        'douyin'=>'https://open.douyin.com/', //抖音
35
+        'toutiao'=>'https://open.snssdk.com/', //头条
36
+        'xigua'=>'https://open-api.ixigua.com/', //西瓜
37 37
     ];
38 38
 
39
-    public $oauth_type = ConstCode::TYPE_DOUYIN;//抖音
39
+    public $oauth_type = ConstCode::TYPE_DOUYIN; //抖音
40 40
 
41 41
     /**
42 42
      * @param $config
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
             'redirect_uri'  => $this->config['callback'],
67 67
             'response_type' => $this->config['response_type'],
68 68
             'scope'         => $this->config['scope'],
69
-            'optionalScope' => $this->config['optionalScope']??'',
69
+            'optionalScope' => $this->config['optionalScope'] ?? '',
70 70
             'state'         => $this->config['state'],
71 71
         ];
72
-        if($params['state'] == 'login_id'){
72
+        if ($params['state'] == 'login_id') {
73 73
             /**
74 74
              * 抖音静默获取授权码
75 75
              * https://developer.open-douyin.com/docs/resource/zh-CN/dop/develop/openapi/account-permission/douyin-default-get-permission-code
76 76
              */
77
-            return $this->AuthorizeSilenceURL . '?' . http_build_query($params);
78
-        }else{
79
-            return $this->AuthorizeURL . '?' . http_build_query($params);
77
+            return $this->AuthorizeSilenceURL.'?'.http_build_query($params);
78
+        } else {
79
+            return $this->AuthorizeURL.'?'.http_build_query($params);
80 80
         }
81 81
     }
82 82
 
@@ -115,10 +115,10 @@  discard block
 block discarded – undo
115 115
             'access_token'=> $this->token['access_token'] ?? '',
116 116
             'union_id'=> $this->token['unionid'] ?? '',
117 117
             'channel' => $this->oauth_type,
118
-            'nickname'=> $result['nickname']??'',
118
+            'nickname'=> $result['nickname'] ?? '',
119 119
             'gender'  => $result['gender'] ?? ConstCode::GENDER,
120
-            'type'  => ConstCode::getTypeConst($this->oauth_type,$this->type),
121
-            'avatar'  => $result['avatar']??'',
120
+            'type'  => ConstCode::getTypeConst($this->oauth_type, $this->type),
121
+            'avatar'  => $result['avatar'] ?? '',
122 122
             'native'   => $result,
123 123
         ];
124 124
         return $userInfo;
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
      */
134 134
     public function getUserInfo()
135 135
     {
136
-        if($this->type == 'app'){//App登录
137
-            if(!isset($_REQUEST['access_token']) ){
136
+        if ($this->type == 'app') {//App登录
137
+            if (!isset($_REQUEST['access_token'])) {
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
         }
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
      * @return array|mixed|null
161 161
      * @throws OAuthException
162 162
      */
163
-    public function applets(){
163
+    public function applets() {
164 164
         /** 获取参数 */
165 165
         $params = $this->jscode2sessionParams();
166 166
 
167 167
         /** 获取access_token */
168
-        $token =  $this->get($this->jsCode2Session, $params);
168
+        $token = $this->get($this->jsCode2Session, $params);
169 169
         /** 解析token值(子类实现此方法) */
170 170
         $this->token = $this->parseToken($token);
171 171
         return $this->token;
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
      */
179 179
     private function switchAccessTokenURL()
180 180
     {
181
-        switch ($this->oauth_type){
182
-            case ConstCode::TYPE_DOUYIN:$this->ApiBase = $this->API_BASE_ARRAY['douyin'];break;
183
-            case ConstCode::TYPE_TOUTIAO:$this->ApiBase = $this->API_BASE_ARRAY['toutiao'];break;
184
-            case ConstCode::TYPE_XIGUA:$this->ApiBase = $this->API_BASE_ARRAY['xigua'];break;
181
+        switch ($this->oauth_type) {
182
+            case ConstCode::TYPE_DOUYIN:$this->ApiBase = $this->API_BASE_ARRAY['douyin']; break;
183
+            case ConstCode::TYPE_TOUTIAO:$this->ApiBase = $this->API_BASE_ARRAY['toutiao']; break;
184
+            case ConstCode::TYPE_XIGUA:$this->ApiBase = $this->API_BASE_ARRAY['xigua']; break;
185 185
             default:throw new OAuthException("获取抖音 OAUTH_TYPE 参数出错:{$this->oauth_type}");
186 186
         }
187 187
         $this->AccessTokenURL = $this->ApiBase.$this->AccessTokenURL;
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
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'])) $params['code'] = $_REQUEST['code'];
222
+        if (isset($_REQUEST['anonymous_code'])) $params['anonymous_code'] = $_REQUEST['anonymous_code'];
223 223
 
224 224
         return $params;
225 225
     }
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         $data = json_decode($token, true);
238 238
         if (isset($data['data']['access_token'])) {
239 239
             return $data['data'];
240
-        }elseif (isset($data['session_key'])){
240
+        }elseif (isset($data['session_key'])) {
241 241
             //小程序登录
242 242
             return $data;
243 243
         } else {
Please login to merge, or discard this patch.
Braces   +10 added lines, -6 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 {
Please login to merge, or discard this patch.
src/Gateways/Csdn.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             'state'         => $this->config['state'],
68 68
             'scope'         => $this->config['scope'],
69 69
         ];
70
-        return $this->AuthorizeURL . '?' . http_build_query($params);
70
+        return $this->AuthorizeURL.'?'.http_build_query($params);
71 71
     }
72 72
 
73 73
     /**
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
     public function getUserInfo()
79 79
     {
80 80
         $this->openid();
81
-        $data = $this->get(static::API_BASE . $this->UserInfoURL, [
81
+        $data = $this->get(static::API_BASE.$this->UserInfoURL, [
82 82
             'access_token' => $this->token['access_token']
83 83
         ]);
84 84
         $data = json_decode($data, true);
85 85
         
86
-        if(!isset($data['username'])) {
87
-            throw new OAuthException("获取CSDN用户信息失败:" . ($data['error_description'] ?? '未知错误'));
86
+        if (!isset($data['username'])) {
87
+            throw new OAuthException("获取CSDN用户信息失败:".($data['error_description'] ?? '未知错误'));
88 88
         }
89 89
         return $data;
90 90
     }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
         if (isset($data['access_token'])) {
113 113
             return $data;
114 114
         }
115
-        throw new OAuthException("获取CSDN ACCESS_TOKEN出错:" . ($data['error_description'] ?? '未知错误'));
115
+        throw new OAuthException("获取CSDN ACCESS_TOKEN出错:".($data['error_description'] ?? '未知错误'));
116 116
     }
117 117
 
118 118
     /**
Please login to merge, or discard this patch.
src/Gateways/Baidu.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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']);
Please login to merge, or discard this patch.
src/Gateways/Line.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Gateways/Qq.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Gateways/Google.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Gateways/Twitter.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.