mp.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // @description 微信公共平台的接口
  2. package gowechat
  3. import (
  4. "github.com/yaotian/gowechat/mp/jssdk"
  5. "github.com/yaotian/gowechat/mp/material"
  6. "github.com/yaotian/gowechat/mp/menu"
  7. "github.com/yaotian/gowechat/mp/oauth"
  8. "github.com/yaotian/gowechat/mp/template"
  9. "github.com/yaotian/gowechat/mp/user"
  10. )
  11. //GetAccessToken 获取access_token
  12. func (wc *Wechat) GetAccessToken() (string, error) {
  13. return wc.Context.GetAccessToken()
  14. }
  15. // GetOauth oauth2网页授权
  16. func (wc *Wechat) GetOauth() *oauth.Oauth {
  17. return oauth.NewOauth(wc.Context)
  18. }
  19. // GetMaterial 素材管理
  20. func (wc *Wechat) GetMaterial() *material.Material {
  21. return material.NewMaterial(wc.Context)
  22. }
  23. // GetJs js-sdk配置
  24. func (wc *Wechat) GetJs() *jssdk.Js {
  25. return jssdk.NewJs(wc.Context)
  26. }
  27. // GetMenu 菜单管理接口
  28. func (wc *Wechat) GetMenu() *menu.Menu {
  29. return menu.NewMenu(wc.Context)
  30. }
  31. // GetUser 用户管理接口
  32. func (wc *Wechat) GetUser() *user.User {
  33. return user.NewUser(wc.Context)
  34. }
  35. // GetTemplate 模板消息接口
  36. func (wc *Wechat) GetTemplate() *template.Template {
  37. return template.NewTemplate(wc.Context)
  38. }