Ver código fonte

active sending audio worked

master
Patrick Peng Sun 8 anos atrás
pai
commit
4bd5fcbf3b
2 arquivos alterados com 27 adições e 1 exclusões
  1. +24
    -0
      kfsend.go
  2. +3
    -1
      kfsend_test.go

+ 24
- 0
kfsend.go Ver arquivo

@@ -54,3 +54,27 @@ func kfSendPicByMediaID(user, mediaID string) {
j, _ := json.Marshal(s)
postJSON(j, u)
}

type sendVoiceMsg struct {
ToUser string `json:"touser"`
MsgType string `json:"msgtype"`
Voice struct {
MediaID string `json:"media_id"`
} `json:"voice"`
}

func kfSendVoice(user, path string) {
mID := uploadVoice(path)
kfSendVoiceByMediaID(user, mID)
}

func kfSendVoiceByMediaID(user, mediaID string) {
u := getKfSendURL()
s := sendVoiceMsg{}
s.ToUser = user
s.MsgType = "voice"
s.Voice.MediaID = mediaID

j, _ := json.Marshal(s)
postJSON(j, u)
}

+ 3
- 1
kfsend_test.go Ver arquivo

@@ -20,7 +20,9 @@ func TestSendPic(t *testing.T) {
}

func TestSendVoice(t *testing.T) {

SetupConfig()
kfSendVoice(toUser, "media_for_test/example.amr")
//kfSendVoiceByMediaID(toUser, "8Tc-pcFxEMtbO6T71AaL0A16taJUpwolXpB06mBBfaPZ68R3__1nN7HuZAUyW8xR")
}

func TestSendVideo(t *testing.T) {

Carregando…
Cancelar
Salvar