Help us shape the future of Go! Take the 2026 Go Developer Survey

message

package
v2.1.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Overview

Package message 消息推送,实现企业微信消息推送相关接口:https://developer.work.weixin.qq.com/document/path/90235

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*context.Context
}

Client 消息推送接口实例

func NewClient

func NewClient(ctx *context.Context) *Client

NewClient 初始化实例

func (*Client) Send

func (r *Client) Send(apiName string, request interface{}) (*SendResponse, error)

Send 发送应用消息 @desc 实现企业微信发送应用消息接口:https://developer.work.weixin.qq.com/document/path/90236

func (*Client) SendImage

func (r *Client) SendImage(request SendImageRequest) (*SendResponse, error)

SendImage 发送图片消息

func (*Client) SendText

func (r *Client) SendText(request SendTextRequest) (*SendResponse, error)

SendText 发送文本消息

func (*Client) SendVoice

func (r *Client) SendVoice(request SendVoiceRequest) (*SendResponse, error)

SendVoice 发送语音消息

type ImageField

type ImageField struct {
	// 图片媒体文件id,可以调用上传临时素材接口获取
	MediaID string `json:"media_id"`
}

ImageField 图片消息参数

type SendImageRequest

type SendImageRequest struct {
	*SendRequestCommon
	Image ImageField `json:"image"`
}

SendImageRequest 发送图片消息的请求

type SendRequestCommon

type SendRequestCommon struct {
	// 指定接收消息的成员,成员ID列表(多个接收者用‘|’分隔,最多支持1000个)。 特殊情况:指定为"@all",则向该企业应用的全部成员发送
	ToUser string `json:"touser"`
	// 指定接收消息的部门,部门ID列表,多个接收者用‘|’分隔,最多支持100个。 当touser为"@all"时忽略本参数
	ToParty string `json:"toparty"`
	// 指定接收消息的标签,标签ID列表,多个接收者用‘|’分隔,最多支持100个。 当touser为"@all"时忽略本参数
	ToTag string `json:"totag"`
	// 消息类型,此时固定为:text
	MsgType string `json:"msgtype"`
	// 企业应用的id,整型。企业内部开发,可在应用的设置页面查看;第三方服务商,可通过接口 获取企业授权信息 获取该参数值
	AgentID string `json:"agentid"`
	// 表示是否是保密消息,0表示可对外分享,1表示不能分享且内容显示水印,默认为0
	Safe int `json:"safe"`
	// 表示是否开启id转译,0表示否,1表示是,默认0。仅第三方应用需要用到,企业自建应用可以忽略。
	EnableIDTrans int `json:"enable_id_trans"`
	// 表示是否开启重复消息检查,0表示否,1表示是,默认0
	EnableDuplicateCheck int `json:"enable_duplicate_check"`
	// 表示是否重复消息检查的时间间隔,默认1800s,最大不超过4小时
	DuplicateCheckInterval int `json:"duplicate_check_interval"`
}

SendRequestCommon 发送应用消息请求公共参数

type SendResponse

type SendResponse struct {
	util.CommonError
	InvalidUser    string `json:"invaliduser"`    // 不合法的userid,不区分大小写,统一转为小写
	InvalidParty   string `json:"invalidparty"`   // 不合法的partyid
	InvalidTag     string `json:"invalidtag"`     // 不合法的标签id
	UnlicensedUser string `json:"unlicenseduser"` // 没有基础接口许可(包含已过期)的userid
	MsgID          string `json:"msgid"`          // 消息id
	ResponseCode   string `json:"response_code"`
}

SendResponse 发送应用消息响应参数

type SendTextRequest

type SendTextRequest struct {
	*SendRequestCommon
	Text TextField `json:"text"`
}

SendTextRequest 发送文本消息的请求

type SendVoiceRequest

type SendVoiceRequest struct {
	*SendRequestCommon
	Voice VoiceField `json:"voice"`
}

SendVoiceRequest 发送语音消息的请求

type TextField

type TextField struct {
	// 消息内容,最长不超过2048个字节,超过将截断(支持id转译)
	Content string `json:"content"`
}

TextField 文本消息参数

type VoiceField

type VoiceField struct {
	// 语音文件id,可以调用上传临时素材接口获取
	MediaID string `json:"media_id"`
}

VoiceField 语音消息参数

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL