| @@ 230-247 (lines=18) @@ | ||
| 227 | * |
|
| 228 | * @return string |
|
| 229 | */ |
|
| 230 | public function getTokenFromServer() |
|
| 231 | { |
|
| 232 | $params = [ |
|
| 233 | 'appid' => $this->appId, |
|
| 234 | 'secret' => $this->secret, |
|
| 235 | 'grant_type' => 'client_credential', |
|
| 236 | ]; |
|
| 237 | ||
| 238 | $http = $this->getHttp(); |
|
| 239 | ||
| 240 | $token = $http->parseJSON($http->get(self::API_TOKEN_GET, $params)); |
|
| 241 | ||
| 242 | if (empty($token[$this->tokenJsonKey])) { |
|
| 243 | throw new HttpException('Request AccessToken fail. response: '.json_encode($token, JSON_UNESCAPED_UNICODE)); |
|
| 244 | } |
|
| 245 | ||
| 246 | return $token; |
|
| 247 | } |
|
| 248 | ||
| 249 | /** |
|
| 250 | * Return the http instance. |
|
| @@ 60-77 (lines=18) @@ | ||
| 57 | /** |
|
| 58 | * {@inheritdoc}. |
|
| 59 | */ |
|
| 60 | public function getTokenFromServer() |
|
| 61 | { |
|
| 62 | $data = [ |
|
| 63 | 'component_appid' => $this->appId, |
|
| 64 | 'component_appsecret' => $this->secret, |
|
| 65 | 'component_verify_ticket' => $this->verifyTicket->getTicket(), |
|
| 66 | ]; |
|
| 67 | ||
| 68 | $http = $this->getHttp(); |
|
| 69 | ||
| 70 | $token = $http->parseJSON($http->json(self::API_TOKEN_GET, $data)); |
|
| 71 | ||
| 72 | if (empty($token[$this->tokenJsonKey])) { |
|
| 73 | throw new HttpException('Request ComponentAccessToken fail. response: '.json_encode($token, JSON_UNESCAPED_UNICODE)); |
|
| 74 | } |
|
| 75 | ||
| 76 | return $token; |
|
| 77 | } |
|
| 78 | } |
|
| 79 | ||