You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
660 B
32 lines
660 B
<?php
|
|
|
|
namespace WeWork\ApiCache;
|
|
|
|
use WeWork\Traits\CorpIdTrait;
|
|
use WeWork\Traits\HttpClientTrait;
|
|
use WeWork\Traits\SecretTrait;
|
|
|
|
class Token extends AbstractApiCache
|
|
{
|
|
use CorpIdTrait, SecretTrait, HttpClientTrait;
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
protected function getCacheKey(): string
|
|
{
|
|
$unique = md5($this->secret);
|
|
|
|
return md5('wework.api.token.' . $unique);
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
protected function getFromServer(): string
|
|
{
|
|
$data = $this->httpClient->get('gettoken', ['corpid' => $this->corpId, 'corpsecret' => $this->secret]);
|
|
|
|
return $data['access_token'];
|
|
}
|
|
}
|
|
|