| @@ 100-113 (lines=14) @@ | ||
| 97 | * |
|
| 98 | * @return string |
|
| 99 | */ |
|
| 100 | public function ticket() |
|
| 101 | { |
|
| 102 | $key = self::TICKET_CACHE_PREFIX.$this->getAccessToken()->getAppId(); |
|
| 103 | ||
| 104 | if ($ticket = $this->getCache()->fetch($key)) { |
|
| 105 | return $ticket; |
|
| 106 | } |
|
| 107 | ||
| 108 | $result = $this->parseJSON('get', [self::API_TICKET, ['type' => 'jsapi']]); |
|
| 109 | ||
| 110 | $this->getCache()->save($key, $result['ticket'], $result['expires_in'] - 500); |
|
| 111 | ||
| 112 | return $result['ticket']; |
|
| 113 | } |
|
| 114 | ||
| 115 | /** |
|
| 116 | * Build signature. |
|
| @@ 177-192 (lines=16) @@ | ||
| 174 | * |
|
| 175 | * @return string $apiTicket |
|
| 176 | */ |
|
| 177 | public function getAPITicket($refresh = false) |
|
| 178 | { |
|
| 179 | $key = self::TICKET_CACHE_PREFIX.$this->getAccessToken()->getAppId(); |
|
| 180 | ||
| 181 | $ticket = $this->getCache()->fetch($key); |
|
| 182 | ||
| 183 | if (!$ticket || $refresh) { |
|
| 184 | $result = $this->parseJSON('get', [self::API_GET_CARD_TICKET, ['type' => 'wx_card']]); |
|
| 185 | ||
| 186 | $this->getCache()->save($key, $result['ticket'], $result['expires_in'] - 500); |
|
| 187 | ||
| 188 | return $result['ticket']; |
|
| 189 | } |
|
| 190 | ||
| 191 | return $ticket; |
|
| 192 | } |
|
| 193 | ||
| 194 | /** |
|
| 195 | * 微信卡券:JSAPI 卡券Package - 基础参数没有附带任何值 - 再生产环境中需要根据实际情况进行修改. |
|