Browse Source

reply image success

master
Patrick Peng Sun 8 years ago
parent
commit
2f7e29f654
2 changed files with 10 additions and 1 deletions
  1. +7
    -0
      outMsg.go
  2. +3
    -1
      server.go

+ 7
- 0
outMsg.go View File

</xml>` </xml>`
} }


//upload image to media as temp data, get mediaid and send it out
func buildUploadPicMsg(ToUserName, path string) (msg string) {

mediaID := uploadImage(path)
msg = buildPicMsg(ToUserName, mediaID)
return
}
func buildPicMsg(ToUserName, mediaID string) (msg string) { func buildPicMsg(ToUserName, mediaID string) (msg string) {
msg = fmt.Sprintf(picMsgTemplate(), ToUserName, APIConfig.PublicAccountID, int32(time.Now().Unix()), mediaID) msg = fmt.Sprintf(picMsgTemplate(), ToUserName, APIConfig.PublicAccountID, int32(time.Now().Unix()), mediaID)
return return

+ 3
- 1
server.go View File

reply, _ = BuildTextMsg(a.Event+"/"+a.EventKey, h.FromUserName) reply, _ = BuildTextMsg(a.Event+"/"+a.EventKey, h.FromUserName)
} }
mediaID := "cU8BYvAEp3H25V-yGO3WBtMVk2bZcEBgf_kje7V-EPkRA_U4x-OAWb_ONg6Y-Qxt" //video mediaID := "cU8BYvAEp3H25V-yGO3WBtMVk2bZcEBgf_kje7V-EPkRA_U4x-OAWb_ONg6Y-Qxt" //video
//mediaID := "e2iNEiSxCX5TV1WbFd0TQMqvVrqFDbDOacdjgQ-OAuE" //new
//mediaID := "e2iNEiSxCX5TV1WbFd0TQMqvVrqFDbDOacdjgQ-OAuE" //news
reply = buildVideoMsg(h.FromUserName, mediaID, "标题123", a.Event+"/"+a.EventKey) reply = buildVideoMsg(h.FromUserName, mediaID, "标题123", a.Event+"/"+a.EventKey)

reply = buildUploadPicMsg(h.FromUserName, "media_for_test/640x480.jpg")
} }
w.Header().Set("Content-Type", "text/xml; charset=utf-8") w.Header().Set("Content-Type", "text/xml; charset=utf-8")
fmt.Fprint(w, reply) fmt.Fprint(w, reply)

Loading…
Cancel
Save