Exemple #1
0
 /**
  * 获取颜色列表.
  *
  * @return array
  */
 public function lists()
 {
     $key = 'overtrue.wechat.colors';
     return $this->cache->get($key, function ($key) {
         $result = $this->http->get(self::API_LIST);
         $this->cache->set($key, $result['colors'], 86400);
         // 1 day
         return $result['colors'];
     });
 }
Exemple #2
0
 /**
  * Get jsticket.
  *
  * @return string
  */
 public function ticket()
 {
     $key = self::TICKET_CACHE_PREFIX . $this->appId;
     return $this->cache->get($key, function ($key) {
         $result = $this->http->get(self::API_TICKET);
         $this->cache->set($key, $result['ticket'], $result['expires_in'] - 500);
         return $result['ticket'];
     });
 }
Exemple #3
0
 /**
  * Get jsticket.
  *
  * @return string
  */
 public function getTicket()
 {
     $key = 'overtrue.wechat.jsapi_ticket.' . $this->appId;
     return $this->cache->get($key, function ($key) {
         $result = $this->http->get(self::API_TICKET);
         $this->cache->set($key, $result['ticket'], $result['expires_in'] - 100);
         return $result['ticket'];
     });
 }
Exemple #4
0
 /**
  * Get jsticket.
  *
  * @return string
  */
 public function getTicket()
 {
     $key = 'overtrue.wechat.jsapi_ticket' . $this->appId;
     // for php 5.3
     $appId = $this->appId;
     $secret = $this->secret;
     $cache = $this->cache;
     $http = $this->http;
     $apiTicket = self::API_TICKET;
     return $this->cache->get($key, function ($key) use($appId, $secret, $cache, $http, $apiTicket) {
         $result = $http->get($apiTicket);
         $cache->set($key, $result['ticket'], $result['expires_in']);
         return $result['ticket'];
     });
 }