浏览代码

active sending audio worked

master
Patrick Peng Sun 8 年前
父节点
当前提交
4bd5fcbf3b
共有 2 个文件被更改,包括 27 次插入1 次删除
  1. +24
    -0
      kfsend.go
  2. +3
    -1
      kfsend_test.go

+ 24
- 0
kfsend.go 查看文件

@@ -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 查看文件

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

正在加载...
取消
保存