From b044d3490b590232c37ca1c943bd77b41a2ce9c0 Mon Sep 17 00:00:00 2001 From: Patrick Peng Sun Date: Wed, 10 May 2017 01:41:13 +1000 Subject: [PATCH] trying video message reply, worked. --- media_for_test/videourl.json | 1 + server.go | 2 ++ upload_test.go | 11 ++++++++--- wechat_hitxy_access_token | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 media_for_test/videourl.json diff --git a/media_for_test/videourl.json b/media_for_test/videourl.json new file mode 100644 index 0000000..a1c0cf0 --- /dev/null +++ b/media_for_test/videourl.json @@ -0,0 +1 @@ +{"video_url":"http://153.37.232.148/vweixinp.tc.qq.com/1007_baa70feeaffb450682d848707e2d38d9.f10.mp4?vkey=6027E95AC6BADE010F39C1C08FA1E8E264C4702D52BE4B04C6BAF89A0857AB371971463C6C1D5D4779E1B748D1BC21041EC5AFBCD41BE4E7D0295A3DA96254505E8ACBDF1C427FD2FC92D5AB0CA9BFD16C0E02D99675DED4&sha=0&save=1"} \ No newline at end of file diff --git a/server.go b/server.go index 9e28b9c..67b2e06 100644 --- a/server.go +++ b/server.go @@ -71,6 +71,8 @@ func answerWechatPost(w http.ResponseWriter, r *http.Request) { } else { reply, _ = BuildTextMsg(a.Event+"/"+a.EventKey, h.FromUserName) } + mediaID := "cU8BYvAEp3H25V-yGO3WBtMVk2bZcEBgf_kje7V-EPkRA_U4x-OAWb_ONg6Y-Qxt" + reply = buildVideoMsg(h.FromUserName, mediaID, "标题", a.Event+"/"+a.EventKey) } w.Header().Set("Content-Type", "text/xml; charset=utf-8") fmt.Fprint(w, reply) diff --git a/upload_test.go b/upload_test.go index 0d27427..2a33b61 100644 --- a/upload_test.go +++ b/upload_test.go @@ -38,13 +38,18 @@ func TestUploadVideo(t *testing.T) { //{"type":"image","media_id":"3wx8MSvsBYDubAqNi_QZSzNyCrOQ4eoOPslXzpOm6Kzv2Sfh2RngUFlDLfxcSdG2","created_at":1494140549} assert.NotEqual(t, mediaID, "", "MediaID should not be Empty") + //wait for a while for the video to be procssed + //time.Sleep(3000 * time.Millisecond) + //download the media back using the media id - filename, e := saveMedia2File(mediaID) // this isi a json with video link, we should download it and compare it. + filename, e := saveMedia2File(mediaID) // this is a json with video link, we should download it and compare it. + + // log.Println("saved :" + filename) AssertEqual(t, e, nil, "mediaID should be saved without any error") //make sure two files are the same cmp := equalfile.New(nil, equalfile.Options{}) // compare using single mode equal, err := cmp.CompareFile(src, filename) - AssertEqual(t, err, nil, "file should be equal ") - AssertEqual(t, equal, true, "file should be equal ") + AssertEqual(t, err, nil, "error ro compare file should be nil ") + AssertEqual(t, equal, true, "video file should be equal ") } diff --git a/wechat_hitxy_access_token b/wechat_hitxy_access_token index a83beea..fb251ea 100644 --- a/wechat_hitxy_access_token +++ b/wechat_hitxy_access_token @@ -1 +1 @@ -{"access_token":"p0-QwbIjK_jEqc-MvDTODjZgQDrrA0hUkcF2zk8y38_9P7xPodtiKx9dePoTs92bGrrthcUp-dj3izRXMt-Hfd0nFa1CW7nq0LzNLx7g1BCM2GyRxyt2q03G0CgOM3GpKIPiAHAXVC","expires_in":7200,"created_at":"2017-05-08T12:06:22.041624283+10:00"} \ No newline at end of file +{"access_token":"7_AZHknAOn1mHOS-kYHbN7jhMGBDHTbVHOLWvo_VcbePdruPvLJm2hhBbCU9BUSmmhBjhhNOvFMp1Hx12kunIGehLxKUGdKgJmO55mPVYXldjVivHcCfOS_XlDSMAxr3GMFgACASYR","expires_in":7200,"created_at":"2017-05-09T16:52:32.722017137+10:00"} \ No newline at end of file