1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
-
-
- package authorization
-
- import (
- "encoding/json"
- "errors"
-
- wxerr "gitee.com/yansen_zh/wxcomponent/errors"
- "gitee.com/yansen_zh/wxcomponent/utils/request"
- )
-
-
- type PushTicketParam struct {
- ComponentAppId string `json:"component_appid"`
- ComponentSecret string `json:"component_secret"`
- }
-
-
- type PushTicketResult struct {
- wxerr.Error
- }
-
- const (
- apiStartPushTicket = "https://apies.weixin.qq.com/cgi-bin/component/api_start_push_ticket"
- )
-
-
- func PushTicket(data PushTicketParam) (*PushTicketResult, error) {
- if data.ComponentAppId == "" {
- return nil, errors.New("启动 ticket 推送服务 第三方平台的 appid 不能为空")
- }
-
- if data.ComponentSecret == "" {
- return nil, errors.New("启动 ticket 推送服务 第三方平台的 appsecret 不能为空")
- }
-
- resp, e2 := request.PostJSON(apiStartPushTicket, nil, data)
- if e2 != nil {
- return nil, e2
- }
-
- result := PushTicketResult{}
- if err := json.Unmarshal(resp, &result); err != nil {
- return nil, err
- }
-
- return &result, nil
- }
|