sendvoice
This commit is contained in:
parent
3a9efa6ff7
commit
a1dc360fac
|
|
@ -51,6 +51,10 @@ type MessageRequest struct {
|
|||
MediaID string `json:"media_id"`
|
||||
} `json:"image"`
|
||||
|
||||
Voice struct {
|
||||
MediaID string `json:"media_id"`
|
||||
} `json:"voice"`
|
||||
|
||||
Video struct {
|
||||
MediaID string `json:"media_id"`
|
||||
Title string `json:"title"`
|
||||
|
|
@ -235,6 +239,33 @@ func (a *App) SendImage(receiver []string, meidiaId string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendVoice(receiver []string, meidiaId string) error {
|
||||
|
||||
url := fmt.Sprintf("%s?access_token=%s", urlQiyeSend, a.GetToken())
|
||||
req := new(MessageRequest)
|
||||
req.MstType = "voice"
|
||||
req.AgentId = a.config.Agent
|
||||
req.ToUser = strings.Join(receiver, "|")
|
||||
req.Voice.MediaID = meidiaId
|
||||
|
||||
data, _ := json.Marshal(req)
|
||||
result, err := util.HttpPostJson(url, nil, data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var rsp BaseResponse
|
||||
err = json.Unmarshal([]byte(result), &rsp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if rsp.ErrCode != 0 {
|
||||
return fmt.Errorf("%d:%s", rsp.ErrCode, rsp.ErrMsg)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) SendVideo(receiver []string, meidiaId, title, desc string) error {
|
||||
|
||||
url := fmt.Sprintf("%s?access_token=%s", urlQiyeSend, a.GetToken())
|
||||
|
|
|
|||
Loading…
Reference in New Issue