WechatMpSDK.php 861 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\common\util\wechat;
  3. use app\common\util\SingleObjectClass;
  4. use EasyWeChat\Factory;
  5. use think\Log;
  6. /**
  7. * 微信小程序实例化对象
  8. * Class MiniProgramSDK
  9. * @package app\common\util
  10. */
  11. class WechatMpSDK
  12. {
  13. protected $app;
  14. /**
  15. * 构造函数
  16. * MiniProgramSDK constructor.
  17. */
  18. public function __construct($config = [])
  19. {
  20. //WxAccountConfig::getMpConfig();//获取小程序配置
  21. $this->app = Factory::officialAccount($config); // Factory::officialAccount($config);
  22. $cache = new WechatCache();
  23. $this->app->rebind('cache', $cache);
  24. Log::record($cache);
  25. //return $this->app;
  26. }
  27. /**
  28. * 获取小程序接口实例
  29. * @return \EasyWeChat\MiniProgram\Application
  30. */
  31. public function getApp()
  32. {
  33. return $this->app;
  34. }
  35. }