| @@ 136-150 (lines=15) @@ | ||
| 133 | * |
|
| 134 | * @return array|mixed |
|
| 135 | */ |
|
| 136 | protected function getUserByToken(AccessTokenInterface $token) |
|
| 137 | { |
|
| 138 | $userUrl = $this->baseUrl.'/oauth/userinfo/'; |
|
| 139 | ||
| 140 | $response = $this->getHttpClient()->get( |
|
| 141 | $userUrl, [ |
|
| 142 | 'query' => [ |
|
| 143 | 'access_token' => $token->getToken(), |
|
| 144 | 'open_id' => $token['open_id'], |
|
| 145 | ], |
|
| 146 | ] |
|
| 147 | ); |
|
| 148 | ||
| 149 | return json_decode($response->getBody(), true); |
|
| 150 | } |
|
| 151 | ||
| 152 | /** |
|
| 153 | * 格式化用户信息. |
|
| @@ 114-126 (lines=13) @@ | ||
| 111 | * |
|
| 112 | * @return array |
|
| 113 | */ |
|
| 114 | protected function getEmailAddress($token) |
|
| 115 | { |
|
| 116 | $url = 'https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))'; |
|
| 117 | ||
| 118 | $response = $this->getHttpClient()->get($url, [ |
|
| 119 | 'headers' => [ |
|
| 120 | 'Authorization' => 'Bearer '.$token, |
|
| 121 | 'X-RestLi-Protocol-Version' => '2.0.0', |
|
| 122 | ], |
|
| 123 | ]); |
|
| 124 | ||
| 125 | return (array) $this->arrayItem(json_decode($response->getBody(), true), 'elements.0.handle~'); |
|
| 126 | } |
|
| 127 | ||
| 128 | /** |
|
| 129 | * {@inheritdoc} |
|