Completed
Push — master ( 5e7dd6...051933 )
by ma
28s queued 27s
created
src/Gateways/Csdn.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
             'state'         => $this->config['state'],
40 40
             'scope'         => $this->config['scope'],
41 41
         ];
42
-        return $this->AuthorizeURL . '?' . http_build_query($params);
42
+        return $this->AuthorizeURL.'?'.http_build_query($params);
43 43
     }
44 44
 
45 45
     /**
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
         $this->openid();
80 80
 
81 81
         $headers = ['Authorization: Bearer '.$this->token['access_token']];
82
-        $data = $this->get($this->UserInfoURL, [],$headers);
82
+        $data = $this->get($this->UserInfoURL, [], $headers);
83 83
         return json_decode($data, true);
84 84
     }
85 85
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * @author: JiaMeng <[email protected]>
102 102
      * Updater:
103 103
      */
104
-    protected function getToken(){
104
+    protected function getToken() {
105 105
         if (empty($this->token)) {
106 106
             /** 验证state参数 */
107 107
             $this->CheckState();
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
             $params = $this->accessTokenParams();
111 111
 
112 112
             /** 获取access_token */
113
-            $this->AccessTokenURL = $this->AccessTokenURL . '?' . http_build_query($params);
114
-            $token =  $this->post($this->AccessTokenURL);
113
+            $this->AccessTokenURL = $this->AccessTokenURL.'?'.http_build_query($params);
114
+            $token = $this->post($this->AccessTokenURL);
115 115
             /** 解析token值(子类实现此方法) */
116 116
             $this->token = $this->parseToken($token);
117 117
         }
Please login to merge, or discard this patch.
example/login.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,20 +10,20 @@
 block discarded – undo
10 10
 //引入配置文件
11 11
 $params = require('config/params.php');
12 12
 
13
-try{
14
-    $name="qq";//登录类型,例:qq / google
13
+try {
14
+    $name = "qq"; //登录类型,例:qq / google
15 15
     $oauth = new oauth2($params);
16 16
     if (empty($_GET['code'])) {
17 17
         /** 登录 */
18 18
         $result = $oauth->login($name);
19 19
 //        var_dump($result['url']);die;
20 20
         //重定向到第三方登录页
21
-        header('Location: ' . $result['url']);
22
-    }else{
21
+        header('Location: '.$result['url']);
22
+    } else {
23 23
         /** 登录回调 */
24 24
         $result = $this->callback($name);
25
-        var_dump($result);die;
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
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
example/proxy/wx_proxy.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
     /**
13 13
      * @Author: TinyMeng <[email protected]>
14 14
      */
15
-    public function run(){
15
+    public function run() {
16 16
         if (isset($_GET['code'])) {
17 17
             $state = isset($_GET['state']) ? $_GET['state'] : "";
18
-            header('Location: ' . $_COOKIE['redirect_uri'] . '?code=' . $_GET['code'] . '&state=' . $state);
18
+            header('Location: '.$_COOKIE['redirect_uri'].'?code='.$_GET['code'].'&state='.$state);
19 19
         } else {
20
-            if(!isset($_GET['appid']) || !isset($_GET['response_type']) || !isset($_GET['scope'])){
20
+            if (!isset($_GET['appid']) || !isset($_GET['response_type']) || !isset($_GET['scope'])) {
21 21
                 echo "参数缺失";
22 22
                 return;
23 23
             }
@@ -26,20 +26,20 @@  discard block
 block discarded – undo
26 26
             $protocol = $this->is_HTTPS() ? 'https://' : 'http://';
27 27
             $params   = array(
28 28
                 'appid'         => $_GET['appid'],
29
-                'redirect_uri'  => $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['DOCUMENT_URI'],
29
+                'redirect_uri'  => $protocol.$_SERVER['HTTP_HOST'].$_SERVER['DOCUMENT_URI'],
30 30
                 'response_type' => $_GET['response_type'],
31 31
                 'scope'         => $_GET['scope'],
32 32
                 'state'         => $state,
33 33
             );
34
-            if($_GET['scope'] == 'snsapi_login'){
34
+            if ($_GET['scope'] == 'snsapi_login') {
35 35
                 //扫码登录
36
-                $AuthorizeURL = $this->AuthorizeURL . '/connect/qrconnect';
37
-            }else{
38
-                $AuthorizeURL = $this->AuthorizeURL . '/connect/oauth2/authorize';
36
+                $AuthorizeURL = $this->AuthorizeURL.'/connect/qrconnect';
37
+            } else {
38
+                $AuthorizeURL = $this->AuthorizeURL.'/connect/oauth2/authorize';
39 39
             }
40 40
 
41 41
             setcookie('redirect_uri', urldecode($_GET['redirect_uri']), $_SERVER['REQUEST_TIME'] + 60, '/');
42
-            header('Location: ' . $AuthorizeURL . '?' . http_build_query($params) . '#wechat_redirect');
42
+            header('Location: '.$AuthorizeURL.'?'.http_build_query($params).'#wechat_redirect');
43 43
         }
44 44
     }
45 45
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      * @Author: TinyMeng <[email protected]>
49 49
      * @return bool
50 50
      */
51
-    protected function is_HTTPS(){
51
+    protected function is_HTTPS() {
52 52
         if (!isset($_SERVER['HTTPS'])) {
53 53
             return false;
54 54
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
example/config/params.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
             'app_id' => 'wx52e2b2464*****',
24 24
             'app_secret' => 'd5dad705a1159d*********',
25 25
             'callback' => $callback,
26
-            'scope'      => 'snsapi_login',//扫码登录
26
+            'scope'      => 'snsapi_login', //扫码登录
27 27
             //'proxy_url' => 'http://www.abc.com/wx_proxy.php',//如果不需要代理请注释此行
28 28
             //'proxy_url' => 'http://www.abc.com/weixin-authorize-proxy.html',//如果不需要代理请注释此行
29 29
         ],
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
             'app_id' => 'wx6ca7410f8******',
32 32
             'app_secret' => '30a206b87b7689b19f11******',
33 33
             'callback' => $callback,
34
-            'scope'      => 'snsapi_userinfo',//静默授权=>snsapi_base;获取用户信息=>snsapi_userinfo
34
+            'scope'      => 'snsapi_userinfo', //静默授权=>snsapi_base;获取用户信息=>snsapi_userinfo
35 35
             //'proxy_url' => 'http://www.abc.com/wx_proxy.php',//如果不需要代理请注释此行
36 36
             //'proxy_url' => 'http://www.abc.com/weixin-authorize-proxy.html',//如果不需要代理请注释此行
37 37
         ],
38 38
         'app'=>[
39 39
             'app_id' => 'wx6ca7410f8******',
40 40
             'app_secret' => '30a206b87b7689b19f11******',
41
-            'type'      => 'app',//登录类型app
41
+            'type'      => 'app', //登录类型app
42 42
         ],
43 43
         /**
44 44
          * 微信小程序只能获取到 openid session_key
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         'applets'=>[
48 48
             'app_id' => 'wx6ca7410f8******',
49 49
             'app_secret' => '30a206b87b7689b19f11******',
50
-            'type'      => 'applets',//登录类型小程序
50
+            'type'      => 'applets', //登录类型小程序
51 51
         ],
52 52
     ]
53 53
     /**
Please login to merge, or discard this patch.
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.