Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:群发视频消息及预览图片消息错误修复 #774

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions officialaccount/broadcast/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ type sendRequest struct {
Mpnews map[string]interface{} `json:"mpnews,omitempty"`
// 发送语音
Voice map[string]interface{} `json:"voice,omitempty"`
// 发送视频
Mpvideo map[string]interface{} `json:"mpvideo,omitempty"`
// 发送图片-预览使用
Image map[string]interface{} `json:"image,omitempty"`
// 发送图片
Images *Image `json:"images,omitempty"`
// 发送卡券
Expand Down Expand Up @@ -183,7 +187,13 @@ func (broadcast *Broadcast) SendImage(user *User, images *Image) (*Result, error
ToUser: nil,
MsgType: MsgTypeImage,
}
req.Images = images
if broadcast.preview {
req.Image = map[string]interface{}{
"media_id": images.MediaIDs[0],
}
} else {
req.Images = images
}
req, sendURL := broadcast.chooseTagOrOpenID(user, req)
url := fmt.Sprintf("%s?access_token=%s", sendURL, ak)
data, err := util.PostJSON(url, req)
Expand All @@ -205,7 +215,7 @@ func (broadcast *Broadcast) SendVideo(user *User, mediaID string, title, descrip
ToUser: nil,
MsgType: MsgTypeVideo,
}
req.Voice = map[string]interface{}{
req.Mpvideo = map[string]interface{}{
"media_id": mediaID,
"title": title,
"description": description,
Expand Down
Loading