ByteDance.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace common\components;
  3. use Yii;
  4. use yii\base\Component;
  5. use Doctrine\Common\Cache\PhpFileCache;
  6. use Doctrine\Common\Cache\RedisCache;
  7. use Qbhy\TtMicroApp\TtMicroApp;
  8. /**
  9. * 抖音小程序
  10. *
  11. * Class ByteDance
  12. * @package common\components
  13. *
  14. * @property \Qbhy\TtMicroApp\TtMicroApp $miniProgram SDK实例
  15. *
  16. * @author jianyan74 <751393839@qq.com>
  17. */
  18. class ByteDance extends Component
  19. {
  20. /**
  21. * Wechat constructor.
  22. * @param array $config
  23. * @throws \yii\base\InvalidConfigException
  24. */
  25. public function __construct($config = [])
  26. {
  27. parent::__construct($config);
  28. $this->initParams();
  29. }
  30. public function initParams()
  31. {
  32. }
  33. /**
  34. * @return TtMicroApp
  35. */
  36. public function getMiniProgram()
  37. {
  38. $directory = Yii::getAlias("@app") . '/runtime/';
  39. $appConfig = [
  40. 'debug' => true,
  41. 'access_key' => Yii::$app->services->config->backendConfig('byte_dance_mini_app_id'),
  42. 'secret_key' => Yii::$app->services->config->backendConfig('byte_dance_mini_app_secret'),
  43. 'payment_app_id' => '',
  44. 'payment_merchant_id' => '',
  45. 'payment_secret' => '',
  46. // 'cache' => new PhpFileCache($directory), // 可选参数,你也可以用 \Doctrine\Common\Cache\ 下面得其他缓存驱动,比如 sqlite 等
  47. 'cache' => new RedisCache(),
  48. ];
  49. return new TtMicroApp($appConfig);
  50. }
  51. }
粤ICP备19079148号