예제 #1
0
 /**
  * 获取第三方平台component_access_token
  * @return bool
  */
 public function getComponentToken()
 {
     $token = Cache::getCache("component_access_token_" . $this->appid);
     if ($token) {
         return $token;
     }
     $url = 'https://api.weixin.qq.com/cgi-bin/component/api_component_token';
     $ticket = Cache::getCache("component_verify_ticket_" . $this->appid);
     if (!$ticket) {
         throw new \Exception("component_verify_ticket 获取失败");
     }
     $arg = array('component_appid' => $this->appid, 'component_appsecret' => $this->appsecret, 'component_verify_ticket' => $ticket);
     $ret = $this->postData($url, $arg);
     if ($ret && !empty($ret['component_access_token'])) {
         Cache::setCache("component_access_token_" . $this->appid, $ret['component_access_token'], $ret['expires_in'] - 120);
         $token = $ret['component_access_token'];
         return $token;
     }
     return false;
 }
예제 #2
0
 /**
  * 清除缓存,按需重载
  * @param string $cachename
  * @return boolean
  */
 protected function removeCache($cachename)
 {
     return Cache::removeCache($cachename);
 }