Documentation ¶
Index ¶
- Constants
- type CDATA
- type CallbackManager
- func (wxcpt *CallbackManager) CallbackVerifyURL(req CallbackVerifyURLReq) (string, error)
- func (wxcpt *CallbackManager) DecryptEnterAgentEvent(req DecryptUserMsgReq) (*EventEnterAgent, error)
- func (wxcpt *CallbackManager) DecryptImageMsg(req DecryptUserMsgReq) (*MsgImage, error)
- func (wxcpt *CallbackManager) DecryptLinkMsg(req DecryptUserMsgReq) (*MsgLink, error)
- func (wxcpt *CallbackManager) DecryptLocationMsg(req DecryptUserMsgReq) (*MsgLocation, error)
- func (wxcpt *CallbackManager) DecryptReportLocationEvent(req DecryptUserMsgReq) (*EventReportLocation, error)
- func (wxcpt *CallbackManager) DecryptSubEvent(req DecryptUserMsgReq) (*EventSub, error)
- func (wxcpt *CallbackManager) DecryptUserMsg(req DecryptUserMsgReq) (*MsgContent, error)
- func (wxcpt *CallbackManager) DecryptVideoMsg(req DecryptUserMsgReq) (*MsgVideo, error)
- func (wxcpt *CallbackManager) DecryptVoiceMsg(req DecryptUserMsgReq) (*MsgVoice, error)
- func (wxcpt *CallbackManager) EncryptUserMsg(req EncryptUserMsgReq) (string, error)
- func (wxcpt *CallbackManager) GetUserEventType(req DecryptUserMsgReq) (string, error)
- func (wxcpt *CallbackManager) GetUserMsgType(req DecryptUserMsgReq) (string, error)
- func (wxcpt *CallbackManager) ReplyUserMsgContent(req MsgContentReply) (string, error)
- func (wxcpt *CallbackManager) ReplyUserMsgImage(req MsgImageReply) (string, error)
- func (wxcpt *CallbackManager) ReplyUserMsgNews(req MsgNewsReply) (string, error)
- func (wxcpt *CallbackManager) ReplyUserMsgTaskCard(req MsgTaskCardReply) (string, error)
- func (wxcpt *CallbackManager) ReplyUserMsgVideo(req MsgVideoReply) (string, error)
- func (wxcpt *CallbackManager) ReplyUserMsgVoice(req MsgVoiceReply) (string, error)
- type CallbackVerifyURLReq
- type CryptError
- type DecryptUserMsgReq
- type EncryptUserMsgReq
- type EventEnterAgent
- type EventReportLocation
- type EventSub
- type EventType
- type EventTypeResp
- type ImageResource
- type MsgContent
- type MsgContentReply
- type MsgImage
- type MsgImageReply
- type MsgLink
- type MsgLocation
- type MsgNewsReply
- type MsgTaskCardReply
- type MsgType
- type MsgTypeResp
- type MsgVideo
- type MsgVideoReply
- type MsgVoice
- type MsgVoiceReply
- type News
- type NewsResource
- type ProtocolProcessor
- type ProtocolType
- type TaskCardResource
- type VideoResource
- type VoiceResource
- type WXBizMsg4Recv
- type WXBizMsg4Send
- type WXBizMsgCrypt
- type XmlProcessor
Constants ¶
const ( ValidateSignatureError int = -40001 ParseXmlError int = -40002 ComputeSignatureError int = -40003 IllegalAesKey int = -40004 ValidateCorpidError int = -40005 EncryptAESError int = -40006 DecryptAESError int = -40007 IllegalBuffer int = -40008 EncodeBase64Error int = -40009 DecodeBase64Error int = -40010 GenXmlError int = -40010 ParseJsonError int = -40012 GenJsonError int = -40013 IllegalProtocolType int = -40014 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallbackManager ¶
type CallbackManager struct {
// contains filtered or unexported fields
}
CallbackManager 回调管理
func NewCallbackManager ¶
func NewCallbackManager(receiver_id string, token string, encodingAESKey string) *CallbackManager
NewCallbackManager 返回一个企业微信加解密实例
func (*CallbackManager) CallbackVerifyURL ¶
func (wxcpt *CallbackManager) CallbackVerifyURL(req CallbackVerifyURLReq) (string, error)
------------使用示例一:验证回调URL--------------- *企业开启回调模式时,企业微信会向验证url发送一个get请求 假设点击验证时,企业收到类似请求: * GET /cgi-bin/wxpush?msg_signature=5c45ff5e21c57e6ad56bac8758b79b1d9ac89fd3×tamp=1409659589&nonce=263014780&echostr=P9nAzCzyDtyTWESHep1vC5X9xho%2FqYX3Zpb4yKa9SKld1DsH3Iyt3tP3zNdtp%2B4RPcs8TgAE7OaBO%2BFZXvnaqQ%3D%3D * HTTP/1.1 Host: qy.weixin.qq.com 接收到该请求时,企业应 1.解析出Get请求的参数,包括消息体签名(msg_signature),时间戳(timestamp),随机数字串(nonce)以及企业微信推送过来的随机加密字符串(echostr), 这一步注意作URL解码。 2.验证消息体签名的正确性 3. 解密出echostr原文,将原文当作Get请求的response,返回给企业微信 第2,3步可以用企业微信提供的库函数VerifyURL来实现。
CallbackVerifyURL 企业微信验证回调URL 参考 https://work.weixin.qq.com/api/doc/90000/90135/90930
func (*CallbackManager) DecryptEnterAgentEvent ¶
func (wxcpt *CallbackManager) DecryptEnterAgentEvent(req DecryptUserMsgReq) (*EventEnterAgent, error)
DecryptEnterAgentEvent 对进入应用事件解密
func (*CallbackManager) DecryptImageMsg ¶
func (wxcpt *CallbackManager) DecryptImageMsg(req DecryptUserMsgReq) (*MsgImage, error)
DecryptImageMsg 对用户回复的图片消息解密
func (*CallbackManager) DecryptLinkMsg ¶
func (wxcpt *CallbackManager) DecryptLinkMsg(req DecryptUserMsgReq) (*MsgLink, error)
DecryptLinkMsg 对用户回复的链接消息解密
func (*CallbackManager) DecryptLocationMsg ¶
func (wxcpt *CallbackManager) DecryptLocationMsg(req DecryptUserMsgReq) (*MsgLocation, error)
DecryptLocationMsg 对用户回复的位置消息解密
func (*CallbackManager) DecryptReportLocationEvent ¶
func (wxcpt *CallbackManager) DecryptReportLocationEvent(req DecryptUserMsgReq) (*EventReportLocation, error)
DecryptReportLocationEvent 对上报位置事件解密
func (*CallbackManager) DecryptSubEvent ¶
func (wxcpt *CallbackManager) DecryptSubEvent(req DecryptUserMsgReq) (*EventSub, error)
DecryptSubEvent 对订阅事件解密
func (*CallbackManager) DecryptUserMsg ¶
func (wxcpt *CallbackManager) DecryptUserMsg(req DecryptUserMsgReq) (*MsgContent, error)
DecryptUserMsg 对用户回复的文本消息解密
func (*CallbackManager) DecryptVideoMsg ¶
func (wxcpt *CallbackManager) DecryptVideoMsg(req DecryptUserMsgReq) (*MsgVideo, error)
DecryptVideoMsg 对用户回复的视频消息解密
func (*CallbackManager) DecryptVoiceMsg ¶
func (wxcpt *CallbackManager) DecryptVoiceMsg(req DecryptUserMsgReq) (*MsgVoice, error)
DecryptVoiceMsg 对用户回复的语音消息解密
func (*CallbackManager) EncryptUserMsg ¶
func (wxcpt *CallbackManager) EncryptUserMsg(req EncryptUserMsgReq) (string, error)
EncryptUserMsg 企业回复的消息加密
func (*CallbackManager) GetUserEventType ¶
func (wxcpt *CallbackManager) GetUserEventType(req DecryptUserMsgReq) (string, error)
GetUserEventType 获取用户事件的事件类型,必须先判断消息类型为event,才能调用该函数
func (*CallbackManager) GetUserMsgType ¶
func (wxcpt *CallbackManager) GetUserMsgType(req DecryptUserMsgReq) (string, error)
GetUserMsgType 获取用户发送消息的消息类型
func (*CallbackManager) ReplyUserMsgContent ¶
func (wxcpt *CallbackManager) ReplyUserMsgContent(req MsgContentReply) (string, error)
EncryptUserMsg 回复文本消息
func (*CallbackManager) ReplyUserMsgImage ¶
func (wxcpt *CallbackManager) ReplyUserMsgImage(req MsgImageReply) (string, error)
ReplyUserMsgImage 回复图片消息
func (*CallbackManager) ReplyUserMsgNews ¶
func (wxcpt *CallbackManager) ReplyUserMsgNews(req MsgNewsReply) (string, error)
ReplyUserMsgNews 回复图文消息
func (*CallbackManager) ReplyUserMsgTaskCard ¶
func (wxcpt *CallbackManager) ReplyUserMsgTaskCard(req MsgTaskCardReply) (string, error)
ReplyUserMsgTaskCard 回复任务卡片
func (*CallbackManager) ReplyUserMsgVideo ¶
func (wxcpt *CallbackManager) ReplyUserMsgVideo(req MsgVideoReply) (string, error)
ReplyUserMsgVideo 回复视频消息
func (*CallbackManager) ReplyUserMsgVoice ¶
func (wxcpt *CallbackManager) ReplyUserMsgVoice(req MsgVoiceReply) (string, error)
ReplyUserMsgVoice 回复语音消息
type CallbackVerifyURLReq ¶
type CallbackVerifyURLReq struct { MsgSignature string Timestamp string Nonce string EchoStr string }
CallbackVerifyURLReq 回调验证URL请求
type CryptError ¶
func NewCryptError ¶
func NewCryptError(err_code int, err_msg string) *CryptError
type DecryptUserMsgReq ¶
type DecryptUserMsgReq struct { MsgSignature string // 签名 Timestamp string Nonce string Data []byte // post请求发送的xml密文数据 }
DecryptUserMsgReq 用户消息解密请求
type EncryptUserMsgReq ¶
EncryptUserMsgReq 企业回复消息加密请求
type EventEnterAgent ¶
type EventEnterAgent struct { ToUsername string `xml:"ToUserName"` //企业微信CorpID FromUsername string `xml:"FromUserName"` //成员UserID CreateTime uint32 `xml:"CreateTime"` //消息创建时间(整型) MsgType string `xml:"MsgType"` //消息类型,此时固定为:event Event string `xml:"Event"` //事件类型:enter_agent EventKey string `xml:"EventKey"` //事件KEY值,此事件该值为空 Agentid uint32 `xml:"AgentId"` //企业应用的id,整型。可在应用的设置页面查看 }
EventEnterAgent 用户进入应用事件
type EventReportLocation ¶
type EventReportLocation struct { ToUsername string `xml:"ToUserName"` //企业微信CorpID FromUsername string `xml:"FromUserName"` //成员UserID CreateTime uint32 `xml:"CreateTime"` //消息创建时间(整型) MsgType string `xml:"MsgType"` //消息类型,此时固定为:event Event string `xml:"Event"` //事件类型:LOCATION Latitude string `xml:"Latitude"` // 地理位置纬度 Longitude string `xml:"Longitude"` // 地理位置经度 Precision string `xml:"Precision"` //地理位置精度 EventKey string `xml:"EventKey"` //事件KEY值,此事件该值为空 Agentid uint32 `xml:"AgentId"` //企业应用的id,整型。可在应用的设置页面查看 AppType string `xml:"AppType"` //app类型,在企业微信固定返回wxwork,在微信不返回该字段 }
EventReportLocation 上报地理位置事件
type EventSub ¶
type EventSub struct { ToUsername string `xml:"ToUserName"` //企业微信CorpID FromUsername string `xml:"FromUserName"` //成员UserID CreateTime uint32 `xml:"CreateTime"` //消息创建时间(整型) MsgType string `xml:"MsgType"` //消息类型,此时固定为:event Event string `xml:"Event"` //事件类型,subscribe(关注)、unsubscribe(取消关注) EventKey string `xml:"EventKey"` //事件KEY值,此事件该值为空 Agentid uint32 `xml:"AgentId"` //企业应用的id,整型。可在应用的设置页面查看 }
EventSub 用户订阅事件
type EventTypeResp ¶
type EventTypeResp struct {
Event string `xml:"Event"` // 事件类型
}
EventTypeResp 获取用户事件类型响应,在MsgType为event时查询
type ImageResource ¶
type ImageResource struct {
MediaId string `xml:"MediaId"` // 图片媒体文件id,可以调用获取媒体文件接口拉取
}
ImageResource 图片资源
type MsgContent ¶
type MsgContent struct { ToUsername string `xml:"ToUserName"` FromUsername string `xml:"FromUserName"` CreateTime uint32 `xml:"CreateTime"` MsgType string `xml:"MsgType"` Content string `xml:"Content"` Msgid string `xml:"MsgId"` Agentid uint32 `xml:"AgentId"` }
MsgContent 用户文本消息内容
type MsgContentReply ¶
type MsgContentReply struct { ToUsername string `xml:"ToUserName"` FromUsername string `xml:"FromUserName"` CreateTime uint32 `xml:"CreateTime"` MsgType string `xml:"MsgType"` Content string `xml:"Content"` }
MsgContentReply 回复用户文本消息内容
type MsgImage ¶
type MsgImage struct { ToUsername string `xml:"ToUserName"` // 企业微信CorpID FromUsername string `xml:"FromUserName"` // 成员UserID CreateTime uint32 `xml:"CreateTime"` // 消息创建时间(整型) MsgType string `xml:"MsgType"` // 消息类型,此时固定为:image PicUrl string `xml:"PicUrl"` // 图片链接 MediaId string `xml:"MediaId"` // 图片媒体文件id,可以调用获取媒体文件接口拉取,仅三天内有效 Msgid string `xml:"MsgId"` // 消息id,64位整型 Agentid uint32 `xml:"AgentId"` // 企业应用的id,整型。可在应用的设置页面查看 }
MsgImage 用户图片消息内容
type MsgImageReply ¶
type MsgImageReply struct { ToUsername string `xml:"ToUserName"` FromUsername string `xml:"FromUserName"` CreateTime uint32 `xml:"CreateTime"` MsgType string `xml:"MsgType"` // 消息类型,此时固定为:image ImageResource []ImageResource `xml:"Image"` }
MsgImageReply 回复用户图片消息内容
type MsgLink ¶
type MsgLink struct { ToUsername string `xml:"ToUserName"` // 企业微信CorpID FromUsername string `xml:"FromUserName"` // 成员UserID CreateTime uint32 `xml:"CreateTime"` // 消息创建时间(整型) MsgType string `xml:"MsgType"` // 消息类型,此时固定为:link Title string `xml:"Title"` // 标题 Description string `xml:"Description"` // 描述 Url string `xml:"Url"` // 链接跳转的url PicUrl string `xml:"PicUrl"` // 封面缩略图的url Msgid string `xml:"MsgId"` // 消息id,64位整型 Agentid uint32 `xml:"AgentId"` // 企业应用的id,整型。可在应用的设置页面查看 }
MsgLink 用户链接消息内容
type MsgLocation ¶
type MsgLocation struct { ToUsername string `xml:"ToUserName"` // 企业微信CorpID FromUsername string `xml:"FromUserName"` // 成员UserID CreateTime uint32 `xml:"CreateTime"` // 消息创建时间(整型) MsgType string `xml:"MsgType"` // 消息类型,此时固定为: location Location_X string `xml:"Location_X"` // 地理位置纬度 Location_Y string `xml:"Location_Y"` // 地理位置经度 Scale uint32 `xml:"Scale"` // 地图缩放大小 Label string `xml:"Label"` //地理位置信息 Msgid string `xml:"MsgId"` // 消息id,64位整型 Agentid uint32 `xml:"AgentId"` // 企业应用的id,整型。可在应用的设置页面查看 }
MsgLocation 用户位置消息内容
type MsgNewsReply ¶
type MsgNewsReply struct { ToUsername string `xml:"ToUserName"` FromUsername string `xml:"FromUserName"` CreateTime uint32 `xml:"CreateTime"` MsgType string `xml:"MsgType"` // 消息类型,此时固定为:news ArticleCount uint32 `xml:"ArticleCount"` // 图文消息的数量 NewsResource []NewsResource `xml:"Articles"` // 图文资源 }
MsgNewsReply 回复用户图文消息内容
type MsgTaskCardReply ¶
type MsgTaskCardReply struct { ToUsername string `xml:"ToUserName"` FromUsername string `xml:"FromUserName"` CreateTime uint32 `xml:"CreateTime"` MsgType string `xml:"MsgType"` // 消息类型,此时固定为:update_taskcard TaskCardResource []TaskCardResource `xml:"TaskCard"` }
MsgTaskCardReply 回复用户任务卡片
type MsgTypeResp ¶
type MsgTypeResp struct {
MsgType string `xml:"MsgType"` // 消息类型
}
MsgTypeResp 获取用户消息类型响应
type MsgVideo ¶
type MsgVideo struct { ToUsername string `xml:"ToUserName"` // 企业微信CorpID FromUsername string `xml:"FromUserName"` // 成员UserID CreateTime uint32 `xml:"CreateTime"` // 消息创建时间(整型) MsgType string `xml:"MsgType"` // 消息类型,此时固定为:video ThumbMediaId string `xml:"ThumbMediaId"` // 视频消息缩略图的媒体id,可以调用获取媒体文件接口拉取数据,仅三天内有效 MediaId string `xml:"MediaId"` // 视频媒体文件id,可以调用获取媒体文件接口拉取数据,仅三天内有效 Msgid string `xml:"MsgId"` // 消息id,64位整型 Agentid uint32 `xml:"AgentId"` // 企业应用的id,整型。可在应用的设置页面查看 }
MsgVideo 用户视频消息内容
type MsgVideoReply ¶
type MsgVideoReply struct { ToUsername string `xml:"ToUserName"` FromUsername string `xml:"FromUserName"` CreateTime uint32 `xml:"CreateTime"` MsgType string `xml:"MsgType"` // 消息类型,此时固定为:video VideoResource []VideoResource `xml:"Video"` }
MsgVideoReply 回复用户视频消息内容
type MsgVoice ¶
type MsgVoice struct { ToUsername string `xml:"ToUserName"` // 企业微信CorpID FromUsername string `xml:"FromUserName"` // 成员UserID CreateTime uint32 `xml:"CreateTime"` // 消息创建时间(整型) MsgType string `xml:"MsgType"` // 消息类型,此时固定为:voice Format string `xml:"Format"` // 语音格式,如amr,speex等 MediaId string `xml:"MediaId"` // 语音媒体文件id,可以调用获取媒体文件接口拉取数据,仅三天内有效 Msgid string `xml:"MsgId"` // 消息id,64位整型 Agentid uint32 `xml:"AgentId"` // 企业应用的id,整型。可在应用的设置页面查看 }
MsgVoice 用户语音消息内容
type MsgVoiceReply ¶
type MsgVoiceReply struct { ToUsername string `xml:"ToUserName"` FromUsername string `xml:"FromUserName"` CreateTime uint32 `xml:"CreateTime"` MsgType string `xml:"MsgType"` // 消息类型,此时固定为:voice VoiceResource []VoiceResource `xml:"Voice"` }
MsgVoiceReply 回复用户语音消息内容
type News ¶
type News struct { Title string `xml:"Title"` // 视频消息的标题,不超过128个字节,超过会自动截断 Description string `xml:"Description"` // 视频消息的描述,不超过512个字节,超过会自动截断 Url string `xml:"Url"` // 点击后跳转的链接。 PicUrl string `xml:"PicUrl"` // 图文消息的图片链接,支持JPG、PNG格式,较好的效果为大图640320,小图8080。 }
News 图文信息
type NewsResource ¶
type NewsResource struct {
Items []News `xml:"item"` // 图文列表项
}
NewsResource 图文资源
type ProtocolProcessor ¶
type ProtocolProcessor interface {
// contains filtered or unexported methods
}
type TaskCardResource ¶
type TaskCardResource struct {
ReplaceName string `xml:"ReplaceName"` // 点击任务卡片按钮后显示的按钮名称
}
TaskCardResource 任务卡片资源
type VideoResource ¶
type VideoResource struct { MediaId string `xml:"MediaId"` // 视频文件id,可以调用获取媒体文件接口拉取 Title string `xml:"Title"` // 视频消息的标题,不超过128个字节,超过会自动截断 Description string `xml:"Description"` // 视频消息的描述,不超过512个字节,超过会自动截断 }
VideoResource 视频资源
type VoiceResource ¶
type VoiceResource struct {
MediaId string `xml:"MediaId"` // 语音文件id,可以调用获取媒体文件接口拉取
}
VoiceResource 语音资源
type WXBizMsg4Recv ¶
type WXBizMsg4Send ¶
type WXBizMsg4Send struct { XMLName xml.Name `xml:"xml"` Encrypt CDATA `xml:"Encrypt"` Signature CDATA `xml:"MsgSignature"` Timestamp string `xml:"TimeStamp"` Nonce CDATA `xml:"Nonce"` }
func NewWXBizMsg4Send ¶
func NewWXBizMsg4Send(encrypt, signature, timestamp, nonce string) *WXBizMsg4Send
type WXBizMsgCrypt ¶
type WXBizMsgCrypt struct {
// contains filtered or unexported fields
}
func NewWXBizMsgCrypt ¶
func NewWXBizMsgCrypt(token, encoding_aeskey, receiver_id string, protocol_type ProtocolType) *WXBizMsgCrypt
type XmlProcessor ¶
type XmlProcessor struct { }