1 | <?php |
||
21 | class AccessToken |
||
22 | { |
||
23 | /** |
||
24 | * @var string client id of app |
||
25 | */ |
||
26 | protected $clientId; |
||
27 | /** |
||
28 | * @var string client secret of app |
||
29 | */ |
||
30 | protected $clientSecret; |
||
31 | /** |
||
32 | * @var \Doctrine\Common\Cache\Cache |
||
33 | */ |
||
34 | protected $cache; |
||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $cacheKeyPrefix = 'easemob.access.token'; |
||
39 | /** |
||
40 | * @var Http |
||
41 | */ |
||
42 | protected $http; |
||
43 | /** |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $token; |
||
47 | |||
48 | 4 | public function __construct( |
|
59 | |||
60 | /** |
||
61 | * @return string |
||
62 | */ |
||
63 | public function getClientId() |
||
67 | |||
68 | /** |
||
69 | * @param string $clientId |
||
70 | */ |
||
71 | public function setClientId($clientId) |
||
75 | |||
76 | /** |
||
77 | * @return string |
||
78 | */ |
||
79 | public function getClientSecret() |
||
83 | |||
84 | /** |
||
85 | * @param string $clientSecret |
||
86 | */ |
||
87 | public function setClientSecret($clientSecret) |
||
91 | |||
92 | /** |
||
93 | * @return \Doctrine\Common\Cache\Cache |
||
94 | */ |
||
95 | 4 | public function getCache() |
|
99 | |||
100 | /** |
||
101 | * @param \Doctrine\Common\Cache\Cache $cache |
||
102 | */ |
||
103 | public function setCache($cache) |
||
107 | |||
108 | /** |
||
109 | * @return Http |
||
110 | */ |
||
111 | public function getHttp() |
||
115 | |||
116 | /** |
||
117 | * @param Http $http |
||
118 | */ |
||
119 | public function setHttp($http) |
||
123 | |||
124 | /** |
||
125 | * Get the access token. |
||
126 | * |
||
127 | * @param bool $forceRefresh |
||
128 | * |
||
129 | * @throws HttpException |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | 4 | public function getToken($forceRefresh = false) |
|
156 | |||
157 | /** |
||
158 | * Internal fetch token logic. |
||
159 | * |
||
160 | * @throws HttpException |
||
161 | * @throws \light\Easemob\Exception\HttpException |
||
162 | * |
||
163 | * @return array |
||
164 | */ |
||
165 | 1 | protected function getTokenFromServer() |
|
184 | } |
||
185 |