Skip to content

Commit

Permalink
fix:群发图片预览消息无效
Browse files Browse the repository at this point in the history
  • Loading branch information
wuweichao committed Mar 28, 2024
1 parent 1797041 commit b721230
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion officialaccount/broadcast/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ type sendRequest struct {
Mpnews map[string]interface{} `json:"mpnews,omitempty"`
// 发送语音
Voice map[string]interface{} `json:"voice,omitempty"`
// 发送图片-预览使用
Image map[string]interface{} `json:"image,omitempty"`
// 发送图片
Images *Image `json:"images,omitempty"`
// 发送卡券
Expand Down Expand Up @@ -183,7 +185,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 Down

0 comments on commit b721230

Please sign in to comment.