From d70f84fa15bcffe507f1b142d17b19af90f78429 Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Fri, 12 May 2017 01:53:35 +1000 Subject: [PATCH] article message sample test finished. --- outMsg.go | 15 +++++++++++++++ server.go | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/outMsg.go b/outMsg.go index 0cd73c6..abff842 100644 --- a/outMsg.go +++ b/outMsg.go @@ -188,6 +188,21 @@ func musicMsgTemplate() string { ` } +func buildSampleArticleMsg(ToUserName string) (msg string) { + art := Article{} + art.title = "bcti" + art.description = "f;alsfjl;dsajfls;ajfl;sajl;fjdsal;fsdla;\nfjsdal;fjasd;lfdas;\n" + art.picURL = "http://placehold.it/360x200" + art.url = "http://doc.biukop.com.au/" + + articles := []Article{} + articles = append(articles, art) + articles = append(articles, art) + articles = append(articles, art) + msg = buildNewsMsg(ToUserName, "标题", "描述", articles) + return +} + func buildNewsMsg(ToUserName, title, description string, articles []Article) (msg string) { count := 0 items := []string{} diff --git a/server.go b/server.go index 9ae5625..178c940 100644 --- a/server.go +++ b/server.go @@ -80,7 +80,8 @@ func answerWechatPost(w http.ResponseWriter, r *http.Request) { //reply = buildUploadPicMsg(h.FromUserName, "media_for_test/640x480.jpg") //reply = buildUploadVoiceMsg(h.FromUserName, "media_for_test/music.mp3") //reply = buildVoiceMsg(h.FromUserName, mediaID) - reply = buildSampleMusicMsg(h.FromUserName) + //reply = buildSampleMusicMsg(h.FromUserName) + reply = buildSampleArticleMsg(h.FromUserName) } w.Header().Set("Content-Type", "text/xml; charset=utf-8") fmt.Fprint(w, reply)