openplatform.go 735 B

12345678910111213141516171819202122232425262728
  1. package openplatform
  2. import (
  3. "github.com/silenceper/wechat/v2/openplatform/config"
  4. "github.com/silenceper/wechat/v2/openplatform/context"
  5. "github.com/silenceper/wechat/v2/openplatform/officialaccount"
  6. )
  7. //OpenPlatform 微信开放平台相关api
  8. type OpenPlatform struct {
  9. *context.Context
  10. }
  11. //NewOpenPlatform new openplatform
  12. func NewOpenPlatform(cfg *config.Config) *OpenPlatform {
  13. if cfg.Cache == nil {
  14. panic("cache 未设置")
  15. }
  16. ctx := &context.Context{
  17. Config: cfg,
  18. }
  19. return &OpenPlatform{ctx}
  20. }
  21. //GetOfficialAccount 公众号代处理
  22. func (openPlatform *OpenPlatform) GetOfficialAccount(appID string) *officialaccount.OfficialAccount {
  23. return officialaccount.NewOfficialAccount(openPlatform.Context, appID)
  24. }