1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace Org\Util;
- use Common\Cache\RedisCache;
- /**
- * 微信公众平台PHP-SDK, ThinkPHP实例
- * @author dodgepudding@gmail.com
- * @link https://github.com/dodgepudding/wechat-php-sdk
- * @version 1.2
- * usage:
- * $options = array(
- * 'token'=>'tokenaccesskey', //填写你设定的key
- * 'encodingaeskey'=>'encodingaeskey', //填写加密用的EncodingAESKey
- * 'appid'=>'wxdk1234567890', //填写高级调用功能的app id
- * 'appsecret'=>'xxxxxxxxxxxxxxxxxxx' //填写高级调用功能的密钥
- * );
- * $weObj = new TPWechat($options);
- * $weObj->valid();
- * ...
- *
- */
- class TPWechat extends \Org\Util\Wechat
- {
- /**
- * log overwrite
- * @see Wechat::log()
- */
- public function log($log){
- if ($this->debug) {
- if (function_exists($this->logcallback)) {
- if (is_array($log)) $log = print_r($log,true);
- return call_user_func($this->logcallback,$log,'INFO');
- }elseif (class_exists('Log')) {
- Log::write('wechat:'.$log, Log::DEBUG);
- return true;
- }
- }
- return false;
- }
- /**
- * 重载设置缓存
- * @param string $cachename
- * @param mixed $value
- * @param int $expired
- * @return boolean
- */
- public function setCache($cachename,$value,$expired){
- $redis_cache = new RedisCache();
- $redis_cache->set($cachename,$value,$expired);
- }
- /**
- * 重载获取缓存
- * @param string $cachename
- * @return mixed
- */
- public function getCache($cachename){
- $redis_cache = new RedisCache();
- return $redis_cache->get($cachename);
- }
- /**
- * 重载清除缓存
- * @param string $cachename
- * @return boolean
- */
- public function removeCache($cachename){
- $redis_cache = new RedisCache();
- return $redis_cache->rm($cachename);
- }
-
- }
|