예제 #1
0
 /**
  * Get token from WeChat API.
  *
  * @return string
  */
 public function getToken()
 {
     $cacheKey = $this->prefix . $this->appId;
     return $this->cache->get($cacheKey, function ($cacheKey) {
         $params = ['appid' => $this->appId, 'secret' => $this->secret, 'grant_type' => 'client_credential'];
         $token = $this->http->get(self::API_TOKEN_GET, $params);
         $this->cache->set($cacheKey, $token['access_token'], $token['expires_in'] - 100);
         return $token['access_token'];
     });
 }
예제 #2
0
파일: Card.php 프로젝트: raymonder/wechat
 /**
  * Get JSSDK ticket.
  *
  * @return string
  */
 public function getTicket()
 {
     if ($this->ticket) {
         return $this->ticket;
     }
     $key = 'overtrue.wechat.card.api_ticket';
     return $this->ticket = $this->cache->get($key, function ($key) {
         $result = $this->http->get(self::API_TICKET);
         $this->cache->set($key, $result['ticket'], $result['expires_in']);
         return $result['ticket'];
     });
 }