国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

BasicWeWork.php 1.0KB

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace WeChat\Contracts;
  3. if (!defined('DEDEINC')) exit('dedebiz');
  4. /**
  5. * 企业微信基础类
  6. * Class BasicWeWork
  7. * @package WeChat\Contracts
  8. */
  9. class BasicWeWork extends BasicWeChat
  10. {
  11. /**
  12. * 获取访问 AccessToken
  13. * @return string
  14. * @throws \WeChat\Exceptions\InvalidResponseException
  15. * @throws \WeChat\Exceptions\LocalCacheException
  16. */
  17. public function getAccessToken()
  18. {
  19. if ($this->access_token) return $this->access_token;
  20. $ckey = $this->config->get('appid').'_access_token';
  21. if ($this->access_token = Tools::getCache($ckey)) return $this->access_token;
  22. list($appid, $secret) = [$this->config->get('appid'), $this->config->get('appsecret')];
  23. $result = Tools::json2arr(Tools::get("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={$appid}&corpsecret={$secret}"));
  24. if (isset($result['access_token']) && $result['access_token']) Tools::setCache($ckey, $result['access_token'], 7000);
  25. return $this->access_token = $result['access_token'];
  26. }
  27. }
  28. ?>