From 2f7e29f6549bdf9aed90f394f63cd2d9b04bdff6 Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Wed, 10 May 2017 17:55:22 +1000 Subject: [PATCH] reply image success --- outMsg.go | 7 +++++++ server.go | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/outMsg.go b/outMsg.go index c0dd650..d71075a 100644 --- a/outMsg.go +++ b/outMsg.go @@ -79,6 +79,13 @@ func txtMsgTemplate() string { ` } +//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) { msg = fmt.Sprintf(picMsgTemplate(), ToUserName, APIConfig.PublicAccountID, int32(time.Now().Unix()), mediaID) return diff --git a/server.go b/server.go index 8140997..fb9f673 100644 --- a/server.go +++ b/server.go @@ -72,8 +72,10 @@ func answerWechatPost(w http.ResponseWriter, r *http.Request) { reply, _ = BuildTextMsg(a.Event+"/"+a.EventKey, h.FromUserName) } 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 = buildUploadPicMsg(h.FromUserName, "media_for_test/640x480.jpg") } w.Header().Set("Content-Type", "text/xml; charset=utf-8") fmt.Fprint(w, reply)