@@ -41,7 +41,7 @@ discard block |
||
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 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'gender' => isset($result['gender']) ? $this->getGender($result['gender']) : ConstCode::GENDER, |
70 | 70 | 'avatar' => $result['picture'], |
71 | 71 | ); |
72 | - if(isset($result['email'])){ |
|
72 | + if (isset($result['email'])) { |
|
73 | 73 | $userInfo['email'] = $result['email']; |
74 | 74 | } |
75 | 75 | return $userInfo; |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function getUserInfo() |
82 | 82 | { |
83 | - if($this->type == 'app'){//App登录 |
|
84 | - if(!isset($_REQUEST['code']) ){ |
|
83 | + if ($this->type == 'app') {//App登录 |
|
84 | + if (!isset($_REQUEST['code'])) { |
|
85 | 85 | throw new \Exception("Google APP登录 需要传输code参数! "); |
86 | 86 | } |
87 | 87 | } |
88 | 88 | $this->getToken(); |
89 | 89 | |
90 | 90 | $headers = array( |
91 | - 'Authorization: Bearer ' . $this->token['access_token'], |
|
91 | + 'Authorization: Bearer '.$this->token['access_token'], |
|
92 | 92 | ); |
93 | 93 | |
94 | 94 | // 创建请求上下文 |
@@ -99,15 +99,15 @@ discard block |
||
99 | 99 | )); |
100 | 100 | |
101 | 101 | try { |
102 | - $data = file_get_contents(self::API_BASE . 'oauth2/v2/userinfo', false, $context); |
|
102 | + $data = file_get_contents(self::API_BASE.'oauth2/v2/userinfo', false, $context); |
|
103 | 103 | // 检查响应是否成功 |
104 | 104 | if ($data !== false) { |
105 | 105 | return json_decode($data, true); |
106 | 106 | } else { |
107 | - throw new \Exception("请求失败 " . $data); |
|
107 | + throw new \Exception("请求失败 ".$data); |
|
108 | 108 | } |
109 | - }catch (Exception $exception){ |
|
110 | - throw new \Exception("异常 " . $exception); |
|
109 | + } catch (Exception $exception) { |
|
110 | + throw new \Exception("异常 ".$exception); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 |
@@ -106,7 +106,7 @@ |
||
106 | 106 | } else { |
107 | 107 | throw new \Exception("请求失败 " . $data); |
108 | 108 | } |
109 | - }catch (Exception $exception){ |
|
109 | + } catch (Exception $exception){ |
|
110 | 110 | throw new \Exception("异常 " . $exception); |
111 | 111 | } |
112 | 112 | } |