| @@ 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. |
|
| @@ 57-75 (lines=19) @@ | ||
| 54 | /** |
|
| 55 | * {@inheritdoc}. |
|
| 56 | */ |
|
| 57 | public function getTokenFromServer() |
|
| 58 | { |
|
| 59 | $data = [ |
|
| 60 | 'component_appid' => $this->appId, |
|
| 61 | 'component_appsecret' => $this->secret, |
|
| 62 | 'component_verify_ticket' => $this->getComponentVerifyTicket() |
|
| 63 | ]; |
|
| 64 | ||
| 65 | $http = $this->getHttp(); |
|
| 66 | ||
| 67 | $token = $http->parseJSON($http->json(self::API_TOKEN_GET, $data)); |
|
| 68 | ||
| 69 | ||
| 70 | if (empty($token[$this->tokenJsonKey])) { |
|
| 71 | throw new HttpException('Request ComponentAccessToken fail. response: ' . json_encode($token, JSON_UNESCAPED_UNICODE)); |
|
| 72 | } |
|
| 73 | ||
| 74 | return $token; |
|
| 75 | } |
|
| 76 | ||
| 77 | /** |
|
| 78 | * Get component verify ticket. |
|