Esempio n. 1
0
 /**
  * 获取jsticket.
  *
  * @return string
  */
 public function getTicket()
 {
     $key = 'overtrue.wechat.jsapi_ticket.' . $this->appId;
     // for php 5.3
     $appId = $this->appId;
     $appSecret = $this->appSecret;
     $cache = $this->cache;
     $apiTicket = self::API_TICKET;
     return $this->cache->get($key, function ($key) use($appId, $appSecret, $cache, $apiTicket) {
         $http = new Http(new AccessToken($appId, $appSecret));
         $result = $http->get($apiTicket);
         $cache->set($key, $result['ticket'], $result['expires_in']);
         return $result['ticket'];
     });
 }
Esempio n. 2
0
 /**
  * 获取jsticket.
  *
  * @return string
  */
 public function getTicket()
 {
     if ($this->ticket) {
         return $this->ticket;
     }
     $key = 'overtrue.wechat.card.api_ticket';
     // for php 5.3
     $http = $this->http;
     $cache = $this->cache;
     $apiTicket = self::API_TICKET;
     return $this->ticket = $this->cache->get($key, function ($key) use($http, $cache, $apiTicket) {
         $result = $http->get($apiTicket);
         $cache->set($key, $result['ticket'], $result['expires_in']);
         return $result['ticket'];
     });
 }