media.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package wechat
  2. import (
  3. "dashoo.cn/opms_libary/plugin/wechat/mp/account"
  4. "dashoo.cn/opms_libary/plugin/wechat/mp/bridge"
  5. "dashoo.cn/opms_libary/plugin/wechat/mp/jssdk"
  6. "dashoo.cn/opms_libary/plugin/wechat/mp/material"
  7. "dashoo.cn/opms_libary/plugin/wechat/mp/menu"
  8. "dashoo.cn/opms_libary/plugin/wechat/mp/oauth"
  9. "dashoo.cn/opms_libary/plugin/wechat/mp/template"
  10. "dashoo.cn/opms_libary/plugin/wechat/mp/user"
  11. "net/http"
  12. )
  13. type Media struct {
  14. *ClientImpl
  15. }
  16. func NewMedia() *Media {
  17. return &Media{}
  18. }
  19. //GetAccessToken 获取access_token
  20. func (c *Media) GetAccessToken() (string, error) {
  21. return c.Context.GetAccessToken()
  22. }
  23. // GetOauth oauth2网页授权
  24. func (c *Media) GetOauth() *oauth.Oauth {
  25. return oauth.NewOauth(c.Context)
  26. }
  27. // GetMaterial 素材管理
  28. func (c *Media) GetMaterial() *material.Material {
  29. return material.NewMaterial(c.Context)
  30. }
  31. // GetJs js-sdk配置
  32. func (c *Media) GetJs() *jssdk.Js {
  33. return jssdk.NewJs(c.Context)
  34. }
  35. // GetMenu 菜单管理接口
  36. func (c *Media) GetMenu() *menu.Menu {
  37. return menu.NewMenu(c.Context)
  38. }
  39. // GetUser 用户管理接口
  40. func (c *Media) GetUser() *user.User {
  41. return user.NewUser(c.Context)
  42. }
  43. // GetTemplate 模板消息接口
  44. func (c *Media) GetTemplate() *template.Template {
  45. return template.NewTemplate(c.Context)
  46. }
  47. // GetMsgHandler 消息管理
  48. func (c *Media) GetMsgHandler(req *http.Request, writer http.ResponseWriter) *bridge.MsgHandler {
  49. c.Context.Request = req
  50. c.Context.Writer = writer
  51. return bridge.NewMsgHandler(c.Context)
  52. }
  53. //GetPageOAuthHandler 网页授权
  54. func (c *Media) GetPageOAuthHandler(req *http.Request, writer http.ResponseWriter, myURLOfPageOAuthCallback string) *bridge.PageOAuthHandler {
  55. c.Context.Request = req
  56. c.Context.Writer = writer
  57. handler := bridge.NewPageOAuthHandler(c.Context, myURLOfPageOAuthCallback)
  58. return handler
  59. }
  60. // GetQrcode 带参数的二维码
  61. func (c *Media) GetQrcode() *account.Qrcode {
  62. return account.NewQrcode(c.Context)
  63. }