Quellcode durchsuchen

trying video message reply, worked.

master
Patrick Peng Sun vor 8 Jahren
Ursprung
Commit
b044d3490b
4 geänderte Dateien mit 12 neuen und 4 gelöschten Zeilen
  1. +1
    -0
      media_for_test/videourl.json
  2. +2
    -0
      server.go
  3. +8
    -3
      upload_test.go
  4. +1
    -1
      wechat_hitxy_access_token

+ 1
- 0
media_for_test/videourl.json Datei anzeigen

@@ -0,0 +1 @@
{"video_url":"http://153.37.232.148/vweixinp.tc.qq.com/1007_baa70feeaffb450682d848707e2d38d9.f10.mp4?vkey=6027E95AC6BADE010F39C1C08FA1E8E264C4702D52BE4B04C6BAF89A0857AB371971463C6C1D5D4779E1B748D1BC21041EC5AFBCD41BE4E7D0295A3DA96254505E8ACBDF1C427FD2FC92D5AB0CA9BFD16C0E02D99675DED4&sha=0&save=1"}

+ 2
- 0
server.go Datei anzeigen

@@ -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)

+ 8
- 3
upload_test.go Datei anzeigen

@@ -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 ")
}

+ 1
- 1
wechat_hitxy_access_token Datei anzeigen

@@ -1 +1 @@
{"access_token":"p0-QwbIjK_jEqc-MvDTODjZgQDrrA0hUkcF2zk8y38_9P7xPodtiKx9dePoTs92bGrrthcUp-dj3izRXMt-Hfd0nFa1CW7nq0LzNLx7g1BCM2GyRxyt2q03G0CgOM3GpKIPiAHAXVC","expires_in":7200,"created_at":"2017-05-08T12:06:22.041624283+10:00"}
{"access_token":"7_AZHknAOn1mHOS-kYHbN7jhMGBDHTbVHOLWvo_VcbePdruPvLJm2hhBbCU9BUSmmhBjhhNOvFMp1Hx12kunIGehLxKUGdKgJmO55mPVYXldjVivHcCfOS_XlDSMAxr3GMFgACASYR","expires_in":7200,"created_at":"2017-05-09T16:52:32.722017137+10:00"}

Laden…
Abbrechen
Speichern