微信相关接口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
981 B

  1. package wechat
  2. import (
  3. "fmt"
  4. )
  5. //发送订阅消息返回结果
  6. type SendSubscribeMessageData struct {
  7. Errcode int `json:"errcode"`
  8. Errmsg string `json:"errmsg"`
  9. }
  10. //发送统一消息返回结果
  11. type SendUniformMessageData struct {
  12. Errcode int `json:"errcode"`
  13. Errmsg string `json:"errmsg"`
  14. }
  15. func SendSubscribeMessage(access_token string, message []byte) (SendSubscribeMessageData, error) {
  16. url := fmt.Sprintf(MINIAPP_SUBSCRIBE_MESSAGE_SEND_API, access_token)
  17. ret, err := PostJson(url, message)
  18. var data SendSubscribeMessageData
  19. if err != nil {
  20. return data, err
  21. }
  22. err = json.Unmarshal(ret, &data)
  23. return data, err
  24. }
  25. func SendUniformMessage(access_token string, message []byte) (SendUniformMessageData, error) {
  26. url := fmt.Sprintf(MINIAPP_UNIFORM_MESSAGE_API, access_token)
  27. ret, err := PostJson(url, message)
  28. var data SendUniformMessageData
  29. if err != nil {
  30. return data, err
  31. }
  32. err = json.Unmarshal(ret, &data)
  33. return data, err
  34. }