@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | 'scope' => $this->config['scope'], |
41 | 41 | 'state' => $this->config['state'], |
42 | 42 | 'display' => $this->display, |
43 | - 'allow_signup' => true,//是否会在OAuth流程中为未经身份验证的用户提供注册GitHub的选项。默认是true。false在策略禁止注册的情况下使用。 |
|
43 | + 'allow_signup' => true, //是否会在OAuth流程中为未经身份验证的用户提供注册GitHub的选项。默认是true。false在策略禁止注册的情况下使用。 |
|
44 | 44 | ]; |
45 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
45 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | { |
99 | 99 | $this->getToken(); |
100 | 100 | |
101 | - $url = self::API_BASE . "user"; |
|
101 | + $url = self::API_BASE."user"; |
|
102 | 102 | $headers = [ |
103 | 103 | 'User-Agent: '.$this->config['application_name'], |
104 | 104 | 'UserModel-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 ', |
105 | - 'Authorization: token ' . $this->token['access_token'], |
|
105 | + 'Authorization: token '.$this->token['access_token'], |
|
106 | 106 | 'Accept: application/json' |
107 | 107 | ]; |
108 | 108 | $response = $this->get($url, [], $headers); |
@@ -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 | } |
@@ -12,12 +12,12 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -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 | } |