@@ -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 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @return mixed|string |
| 143 | 143 | * @throws \Exception |
| 144 | 144 | */ |
| 145 | - private function getOpenID(){ |
|
| 145 | + private function getOpenID() { |
|
| 146 | 146 | $query = [ |
| 147 | 147 | 'access_token' => $this->token['access_token'] |
| 148 | 148 | ]; |
@@ -151,12 +151,12 @@ discard block |
||
| 151 | 151 | $query['unionid'] = 1; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - $data = $this->get(self::API_BASE . 'oauth2.0/me',$query); |
|
| 155 | - $data = json_decode(trim(substr($data, 9), " );\n"), true); |
|
| 154 | + $data = $this->get(self::API_BASE.'oauth2.0/me', $query); |
|
| 155 | + $data = json_decode(trim(substr($data, 9), " );\n"), true); |
|
| 156 | 156 | if (isset($data['openid'])) { |
| 157 | 157 | return $data; |
| 158 | 158 | } else { |
| 159 | - throw new \Exception("获取用户openid出错:" . $data['error_description']); |
|
| 159 | + throw new \Exception("获取用户openid出错:".$data['error_description']); |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * M代表男性,F代表女性 |
| 166 | 166 | * @param $gender |
| 167 | 167 | */ |
| 168 | - public function getGender($gender){ |
|
| 168 | + public function getGender($gender) { |
|
| 169 | 169 | return $gender == '男' ? ConstCode::GENDER_MAN : ConstCode::GENDER_WOMEN; |
| 170 | 170 | } |
| 171 | 171 | } |