Skip to content

Commit

Permalink
Fix template message id.
Browse files Browse the repository at this point in the history
  • Loading branch information
wizjin committed Jan 11, 2016
1 parent 48034b0 commit c3c9676
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions weixin.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ type ResponseWriter interface {
PostVideo(mediaId string, title string, description string) error
PostMusic(music *Music) error
PostNews(articles []Article) error
PostTemplateMessage(templateid string, url string, data TmplData) (string, error)
PostTemplateMessage(templateid string, url string, data TmplData) (int32, error)
// Media operator
UploadMediaFromFile(mediaType string, filepath string) (string, error)
DownloadMediaToFile(mediaId string, filepath string) error
Expand Down Expand Up @@ -573,7 +573,7 @@ func (wx *Weixin) AddTemplate(shortid string) (string, error) {
return templateId.Id, nil
}

func (wx *Weixin) PostTemplateMessage(touser string, templateid string, url string, data TmplData) (string, error) {
func (wx *Weixin) PostTemplateMessage(touser string, templateid string, url string, data TmplData) (int32, error) {
var msg struct {
ToUser string `json:"touser"`
TemplateId string `json:"template_id"`
Expand All @@ -586,17 +586,17 @@ func (wx *Weixin) PostTemplateMessage(touser string, templateid string, url stri
msg.Data = data
msgStr, err := marshal(msg)
if err != nil {
return "", err
return 0, err
}
reply, err := postRequest(weixinHost+"/message/template/send?access_token=", wx.tokenChan, msgStr)
if err != nil {
return "", err
return 0, err
}
var resp struct {
MsgId string `json:"msgid,omitempty"`
MsgId int32 `json:"msgid,omitempty"`
}
if err := json.Unmarshal(reply, &resp); err != nil {
return "", err
return 0, err
}
return resp.MsgId, nil
}
Expand Down Expand Up @@ -1059,7 +1059,7 @@ func (w responseWriter) PostNews(articles []Article) error {
}

// Post template message
func (w responseWriter) PostTemplateMessage(templateid string, url string, data TmplData) (string, error) {
func (w responseWriter) PostTemplateMessage(templateid string, url string, data TmplData) (int32, error) {
return w.wx.PostTemplateMessage(w.toUserName, templateid, url, data)
}

Expand Down

0 comments on commit c3c9676

Please sign in to comment.