コード例 #1
0
ファイル: common.php プロジェクト: elmoy/wenheyou
 /**
  * 获取token
  */
 public function get_accesstoken($key = 'access_token', $default = null)
 {
     \Core\Cache::init_config_params();
     $this->accesstoken = \Core\Cache::get('access_token');
     if (empty($this->accesstoken)) {
         $host = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s";
         $url = sprintf($host, $this->appid, $this->appsecret);
         $info = \Core\Curl::get($url);
         $respone = json_decode($info->response, true);
         if (isset($respone['access_token'])) {
             $this->accesstoken = $respone;
         }
         \Core\Cache::set('access_token', $respone);
     }
     if (!isset($this->accesstoken[$key])) {
         $this->accesstoken[$key] = $default;
     }
     return $this->accesstoken[$key];
 }
コード例 #2
0
ファイル: common.php プロジェクト: elmoy/wenheyou
 private function get_jsapi_ticket($key = 'ticket', $default = null)
 {
     \Core\Cache::init_config_params();
     $this->ticket = \Core\Cache::get('jsapi_ticket');
     if (empty($this->ticket)) {
         $host = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=%s";
         $url = sprintf($host, $this->get_accesstoken());
         $info = \Core\Curl::get($url);
         $respone = json_decode($info->response, true);
         if (isset($respone['ticket'])) {
             $this->ticket = $respone;
         }
         \Core\Cache::set('jsapi_ticket', $respone);
     }
     if (!isset($this->ticket[$key])) {
         $this->ticket[$key] = $default;
     }
     return $this->ticket[$key];
 }
コード例 #3
0
ファイル: common.php プロジェクト: elmoy/wenheyou
 /**
  * 请求token
  */
 public function get_accesstoken($key = 'access_token', $default = null)
 {
     \Core\Cache::init_config_params();
     $this->enterprise_accesstoken = \Core\Cache::get('enterprise_accesstoken');
     if (empty($this->enterprise_accesstoken)) {
         $host = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=%s&corpsecret=%s';
         $url = sprintf($host, $this->corpid, $this->corpsecret);
         $info = \Core\Curl::get($url);
         $respone = json_decode($info->response, true);
         if (isset($respone['access_token'])) {
             $this->enterprise_accesstoken = $respone;
         }
         \Core\Cache::set('enterprise_accesstoken', $respone);
     }
     if (!isset($this->accesstoken[$key])) {
         $this->accesstoken[$key] = $default;
     }
     return $this->accesstoken[$key];
 }