client.go 604 B

123456789101112131415161718192021222324252627
  1. package wechat
  2. import (
  3. "fmt"
  4. mini "github.com/ArtisanCloud/PowerWeChat/v2/src/miniProgram"
  5. )
  6. // NewClient 获取操作小程序的实例
  7. func NewClient(AppId, Secret string) (*mini.MiniProgram, error) {
  8. client, err := mini.NewMiniProgram(&mini.UserConfig{
  9. AppID: AppId,
  10. Secret: Secret,
  11. HttpDebug: true,
  12. Debug: false,
  13. // 可选,不传默认走程序内存
  14. //Cache: kernel.NewRedisClient(&kernel.RedisOptions{
  15. // Addr: RedisAddr,
  16. // Password: "",
  17. // DB: 0,
  18. //}),
  19. })
  20. if err != nil {
  21. fmt.Printf("init wechat miniprogram failed")
  22. }
  23. return client, err
  24. }