TPWechat.class.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * 微信公众平台PHP-SDK, ThinkPHP实例
  4. * @author dodgepudding@gmail.com
  5. * @link https://github.com/dodgepudding/wechat-php-sdk
  6. * @version 1.2
  7. * usage:
  8. * $options = array(
  9. * 'token'=>'tokenaccesskey', //填写你设定的key
  10. * 'encodingaeskey'=>'encodingaeskey', //填写加密用的EncodingAESKey
  11. * 'appid'=>'wxdk1234567890', //填写高级调用功能的app id
  12. * 'appsecret'=>'xxxxxxxxxxxxxxxxxxx' //填写高级调用功能的密钥
  13. * );
  14. * $weObj = new TPWechat($options);
  15. * $weObj->valid();
  16. * ...
  17. *
  18. */
  19. class TPWechat extends Wechat
  20. {
  21. /**
  22. * log overwrite
  23. * @see Wechat::log()
  24. */
  25. protected function log($log){
  26. if ($this->debug) {
  27. if (function_exists($this->logcallback)) {
  28. if (is_array($log)) $log = print_r($log,true);
  29. return call_user_func($this->logcallback,$log);
  30. }elseif (class_exists('Log')) {
  31. Log::write('wechat:'.$log, Log::DEBUG);
  32. return true;
  33. }
  34. }
  35. return false;
  36. }
  37. /**
  38. * 重载设置缓存
  39. * @param string $cachename
  40. * @param mixed $value
  41. * @param int $expired
  42. * @return boolean
  43. */
  44. protected function setCache($cachename,$value,$expired){
  45. return S($cachename,$value,$expired);
  46. }
  47. /**
  48. * 重载获取缓存
  49. * @param string $cachename
  50. * @return mixed
  51. */
  52. protected function getCache($cachename){
  53. return S($cachename);
  54. }
  55. /**
  56. * 重载清除缓存
  57. * @param string $cachename
  58. * @return boolean
  59. */
  60. protected function removeCache($cachename){
  61. return S($cachename,null);
  62. }
  63. }