@@ -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; |
@@ -6,16 +6,16 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | use tinymeng\tools\Tool; |
| 8 | 8 | |
| 9 | -class ConstCode{ |
|
| 9 | +class ConstCode { |
|
| 10 | 10 | |
| 11 | 11 | /** 公共状态 */ |
| 12 | - const STATUS_DELETE = 0;//删除 |
|
| 13 | - const STATUS_NORMAL = 1;//正常 |
|
| 12 | + const STATUS_DELETE = 0; //删除 |
|
| 13 | + const STATUS_NORMAL = 1; //正常 |
|
| 14 | 14 | |
| 15 | 15 | /** 性别 */ |
| 16 | - const GENDER = 0;//未知 |
|
| 17 | - const GENDER_MAN = 1;//男 |
|
| 18 | - const GENDER_WOMEN = 2;//女 |
|
| 16 | + const GENDER = 0; //未知 |
|
| 17 | + const GENDER_MAN = 1; //男 |
|
| 18 | + const GENDER_WOMEN = 2; //女 |
|
| 19 | 19 | |
| 20 | 20 | /** 登录类型 */ |
| 21 | 21 | const TYPE_QQ = 1; //QQ |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | const TYPE_FACEBOOK = 7; //faceBook |
| 28 | 28 | const TYPE_GOOGLE = 8; //google |
| 29 | 29 | const TYPE_TWITTER = 9; //飞鸽 |
| 30 | - const TYPE_LINE = 10;//line |
|
| 31 | - const TYPE_NAVER = 11;//naver |
|
| 30 | + const TYPE_LINE = 10; //line |
|
| 31 | + const TYPE_NAVER = 11; //naver |
|
| 32 | 32 | const TYPE_ALIYUN = 12; //阿里云 |
| 33 | 33 | const TYPE_BAIDU = 13; //百度 |
| 34 | 34 | const TYPE_CODING = 14; //Coding |
@@ -53,24 +53,24 @@ discard block |
||
| 53 | 53 | * @param bool $type 类型:app applets |
| 54 | 54 | * @return int |
| 55 | 55 | */ |
| 56 | - static public function getTypeConst($channel,$type="") |
|
| 56 | + static public function getTypeConst($channel, $type = "") |
|
| 57 | 57 | { |
| 58 | - switch ($channel){ |
|
| 58 | + switch ($channel) { |
|
| 59 | 59 | case self::TYPE_QQ: |
| 60 | - if($type == 'app'){ |
|
| 61 | - $typeConst = self::TYPE_QQ_APP;//qqApp |
|
| 62 | - }else{ |
|
| 60 | + if ($type == 'app') { |
|
| 61 | + $typeConst = self::TYPE_QQ_APP; //qqApp |
|
| 62 | + } else { |
|
| 63 | 63 | $typeConst = $channel; |
| 64 | 64 | } |
| 65 | 65 | break; |
| 66 | 66 | case self::TYPE_WECHAT: |
| 67 | - if($type == 'app'){ |
|
| 68 | - $typeConst = self::TYPE_WECHAT_APP;//微信App |
|
| 69 | - }else if($type == 'applets'){ |
|
| 70 | - $typeConst = self::TYPE_WECHAT_APPLETS;//微信小程序 |
|
| 71 | - }else if(Tool::isWeiXin()){ |
|
| 72 | - $typeConst = self::TYPE_WECHAT_MOBILE;//微信mobile |
|
| 73 | - }else{ |
|
| 67 | + if ($type == 'app') { |
|
| 68 | + $typeConst = self::TYPE_WECHAT_APP; //微信App |
|
| 69 | + } else if ($type == 'applets') { |
|
| 70 | + $typeConst = self::TYPE_WECHAT_APPLETS; //微信小程序 |
|
| 71 | + } else if (Tool::isWeiXin()) { |
|
| 72 | + $typeConst = self::TYPE_WECHAT_MOBILE; //微信mobile |
|
| 73 | + } else { |
|
| 74 | 74 | $typeConst = $channel; |
| 75 | 75 | } |
| 76 | 76 | break; |
@@ -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 | |
@@ -39,7 +39,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -130,7 +130,7 @@ |
||
| 130 | 130 | throw new \Exception("AliPay APP登录 需要传输access_token参数! "); |
| 131 | 131 | } |
| 132 | 132 | $this->token['access_token'] = $_REQUEST['access_token']; |
| 133 | - }else { |
|
| 133 | + } else { |
|
| 134 | 134 | /** 获取token信息 */ |
| 135 | 135 | $this->getToken(); |
| 136 | 136 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | $this->AuthorizeURL = str_replace("alipay", "alipaydev", $this->AuthorizeURL); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - return $this->AuthorizeURL . '?' . http_build_query($params); |
|
| 84 | + return $this->AuthorizeURL.'?'.http_build_query($params); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -114,16 +114,16 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | $userInfo = [ |
| 116 | 116 | 'open_id' => $this->openid(), |
| 117 | - 'union_id' => $this->token['union_id']??'', |
|
| 117 | + 'union_id' => $this->token['union_id'] ?? '', |
|
| 118 | 118 | 'channel' => ConstCode::TYPE_ALIPAY, |
| 119 | 119 | 'nickname' => $result['nick_name'], |
| 120 | 120 | 'gender' => isset($result['gender']) ? $this->getGender($result['gender']) : ConstCode::GENDER, |
| 121 | 121 | 'avatar' => $result['avatar'], |
| 122 | 122 | // 拓展字段 |
| 123 | - 'access_token' => $this->token['access_token']??'', |
|
| 123 | + 'access_token' => $this->token['access_token'] ?? '', |
|
| 124 | 124 | 'user_id' => $this->token['user_id'], |
| 125 | 125 | ]; |
| 126 | - $userInfo['type'] = ConstCode::getTypeConst($userInfo['channel'],$this->type); |
|
| 126 | + $userInfo['type'] = ConstCode::getTypeConst($userInfo['channel'], $this->type); |
|
| 127 | 127 | return $userInfo; |
| 128 | 128 | } |
| 129 | 129 | |
@@ -136,12 +136,12 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | public function getUserInfo() |
| 138 | 138 | { |
| 139 | - if($this->type == 'app'){//App登录 |
|
| 140 | - if(!isset($_REQUEST['access_token']) ){ |
|
| 139 | + if ($this->type == 'app') {//App登录 |
|
| 140 | + if (!isset($_REQUEST['access_token'])) { |
|
| 141 | 141 | throw new \Exception("AliPay APP登录 需要传输access_token参数! "); |
| 142 | 142 | } |
| 143 | 143 | $this->token['access_token'] = $_REQUEST['access_token']; |
| 144 | - }else { |
|
| 144 | + } else { |
|
| 145 | 145 | /** 获取token信息 */ |
| 146 | 146 | $this->getToken(); |
| 147 | 147 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | $data = $this->post(self::API_BASE, $params); |
| 161 | 161 | $data = mb_convert_encoding($data, 'utf-8', 'gbk'); |
| 162 | - $result = json_decode($data, true); |
|
| 162 | + $result = json_decode($data, true); |
|
| 163 | 163 | return $result['alipay_user_info_share_response']; |
| 164 | 164 | } |
| 165 | 165 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | throw new \Exception('支付宝RSA密钥未配置'); |
| 237 | 237 | } |
| 238 | 238 | $rsa = str_replace([PHP_EOL, $header, $footer], '', $rsa); |
| 239 | - $rsaVal = $header . PHP_EOL . chunk_split($rsa, 64, PHP_EOL) . $footer; |
|
| 239 | + $rsaVal = $header.PHP_EOL.chunk_split($rsa, 64, PHP_EOL).$footer; |
|
| 240 | 240 | return $rsaVal; |
| 241 | 241 | } |
| 242 | 242 | |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | if (isset($data['alipay_system_oauth_token_response'])) { |
| 257 | 257 | $data = $data['alipay_system_oauth_token_response']; |
| 258 | - $data['openid'] = $data['open_id']??$data['user_id']; |
|
| 258 | + $data['openid'] = $data['open_id'] ?? $data['user_id']; |
|
| 259 | 259 | return $data; |
| 260 | 260 | } else { |
| 261 | 261 | throw new \Exception("获取支付宝 ACCESS_TOKEN 出错:{$token}"); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | if (!$config) { |
| 92 | 92 | throw new \Exception('传入的配置不能为空'); |
| 93 | 93 | } |
| 94 | - if(isset($_GET['referer']) && $config['callback']){ |
|
| 94 | + if (isset($_GET['referer']) && $config['callback']) { |
|
| 95 | 95 | $config['callback'] .= ((strpos($config['callback'], '?') !== false) ? '&' : '?').'referer='.$_GET['referer']; |
| 96 | 96 | } |
| 97 | 97 | //默认参数 |
@@ -104,11 +104,11 @@ discard block |
||
| 104 | 104 | 'proxy' => '', |
| 105 | 105 | 'state' => '', |
| 106 | 106 | 'type' => '', |
| 107 | - 'is_sandbox' => false,//是否是沙箱环境 |
|
| 107 | + 'is_sandbox' => false, //是否是沙箱环境 |
|
| 108 | 108 | ]; |
| 109 | - $this->config = array_merge($_config, $config); |
|
| 110 | - foreach($this->config as $key=>$val){ |
|
| 111 | - if(property_exists($this,$key)) $this->$key=$val; |
|
| 109 | + $this->config = array_merge($_config, $config); |
|
| 110 | + foreach ($this->config as $key=>$val) { |
|
| 111 | + if (property_exists($this, $key)) $this->$key = $val; |
|
| 112 | 112 | } |
| 113 | 113 | $this->timestamp = time(); |
| 114 | 114 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * Updater: |
| 145 | 145 | * @return $this |
| 146 | 146 | */ |
| 147 | - public function mustCheckState(){ |
|
| 147 | + public function mustCheckState() { |
|
| 148 | 148 | $this->checkState = true; |
| 149 | 149 | return $this; |
| 150 | 150 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @Author: TinyMeng <[email protected]> |
| 155 | 155 | * @return array |
| 156 | 156 | */ |
| 157 | - public function getConfig(){ |
|
| 157 | + public function getConfig() { |
|
| 158 | 158 | return $this->config; |
| 159 | 159 | } |
| 160 | 160 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @param $token |
| 164 | 164 | * @return $this |
| 165 | 165 | */ |
| 166 | - public function setToken($token){ |
|
| 166 | + public function setToken($token) { |
|
| 167 | 167 | $this->token = $token; |
| 168 | 168 | return $this; |
| 169 | 169 | } |
@@ -172,14 +172,14 @@ discard block |
||
| 172 | 172 | * 存储state |
| 173 | 173 | * @Author: TinyMeng <[email protected]> |
| 174 | 174 | */ |
| 175 | - public function saveState(){ |
|
| 175 | + public function saveState() { |
|
| 176 | 176 | if ($this->checkState === true) { |
| 177 | 177 | //是否开启session |
| 178 | 178 | if (session_status() !== PHP_SESSION_ACTIVE) { |
| 179 | 179 | session_start(); |
| 180 | 180 | } |
| 181 | - if(empty($this->config['state'])){ |
|
| 182 | - $this->config['state'] = Str::random();//生成随机state |
|
| 181 | + if (empty($this->config['state'])) { |
|
| 182 | + $this->config['state'] = Str::random(); //生成随机state |
|
| 183 | 183 | } |
| 184 | 184 | //存储到session |
| 185 | 185 | $_SESSION['tinymeng_oauth_state'] = $this->config['state']; |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * @Author: TinyMeng <[email protected]> |
| 192 | 192 | * @throws \Exception |
| 193 | 193 | */ |
| 194 | - public function checkState(){ |
|
| 194 | + public function checkState() { |
|
| 195 | 195 | if ($this->checkState === true) { |
| 196 | 196 | if (session_status() !== PHP_SESSION_ACTIVE) { |
| 197 | 197 | session_start(); |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * @author: JiaMeng <[email protected]> |
| 209 | 209 | * @return string |
| 210 | 210 | */ |
| 211 | - public function getCode(){ |
|
| 211 | + public function getCode() { |
|
| 212 | 212 | return isset($_REQUEST['code']) ? $_REQUEST['code'] : ''; |
| 213 | 213 | } |
| 214 | 214 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * Updater: |
| 219 | 219 | * @return array |
| 220 | 220 | */ |
| 221 | - protected function accessTokenParams(){ |
|
| 221 | + protected function accessTokenParams() { |
|
| 222 | 222 | $params = [ |
| 223 | 223 | 'client_id' => $this->config['app_id'], |
| 224 | 224 | 'client_secret' => $this->config['app_secret'], |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @author: JiaMeng <[email protected]> |
| 235 | 235 | * Updater: |
| 236 | 236 | */ |
| 237 | - protected function getToken(){ |
|
| 237 | + protected function getToken() { |
|
| 238 | 238 | if (empty($this->token)) { |
| 239 | 239 | /** 验证state参数 */ |
| 240 | 240 | $this->checkState(); |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | $params = $this->accessTokenParams(); |
| 244 | 244 | |
| 245 | 245 | /** 获取access_token */ |
| 246 | - $token = $this->POST($this->AccessTokenURL, $params); |
|
| 246 | + $token = $this->POST($this->AccessTokenURL, $params); |
|
| 247 | 247 | /** 解析token值(子类实现此方法) */ |
| 248 | 248 | $this->token = $this->parseToken($token); |
| 249 | - }else{ |
|
| 249 | + } else { |
|
| 250 | 250 | return $this->token; |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | protected function get($url, $params = [], $headers = []) |
| 264 | 264 | { |
| 265 | - return \tinymeng\tools\HttpRequest::httpGet($url, $params,$headers); |
|
| 265 | + return \tinymeng\tools\HttpRequest::httpGet($url, $params, $headers); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -276,8 +276,8 @@ discard block |
||
| 276 | 276 | */ |
| 277 | 277 | protected function post($url, $params = [], $headers = []) |
| 278 | 278 | { |
| 279 | - $headers[] = 'Accept: application/json';//GitHub需要的header |
|
| 280 | - return \tinymeng\tools\HttpRequest::httpPost($url, $params,$headers); |
|
| 279 | + $headers[] = 'Accept: application/json'; //GitHub需要的header |
|
| 280 | + return \tinymeng\tools\HttpRequest::httpPost($url, $params, $headers); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | /** |
@@ -285,8 +285,8 @@ discard block |
||
| 285 | 285 | * M代表男性,F代表女性 |
| 286 | 286 | * @param $gender |
| 287 | 287 | */ |
| 288 | - public function getGender($gender){ |
|
| 289 | - return strtolower(substr($gender , 0 , 1)) == 'm' ? ConstCode::GENDER_MAN : ConstCode::GENDER_WOMEN; |
|
| 288 | + public function getGender($gender) { |
|
| 289 | + return strtolower(substr($gender, 0, 1)) == 'm' ? ConstCode::GENDER_MAN : ConstCode::GENDER_WOMEN; |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | |
@@ -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 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | } |