gowechat

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
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 AccessToken

type AccessToken struct {
	ErrCode     int    `json:"errcode"`
	ErrMsg      string `json:"errmsg"`
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
}

type CDATA

type CDATA struct {
	Value string `xml:",cdata"`
}

type CryptError

type CryptError struct {
	ErrCode int
	ErrMsg  string
}

func NewCryptError

func NewCryptError(err_code int, err_msg string) *CryptError

type Msg

type Msg struct {
	MsgId    string   `json:"msgid"`
	SendTime int64    `json:"send_time"`
	Origin   int      `json:"origin"`
	Msgtype  string   `json:"msgtype"`
	Event    MsgEvent `json:"event"`
	Text     struct {
		Content string `json:"content"`
	} `json:"text"`
	Link struct {
		Title  string `json:"title"`
		Desc   string `json:"desc"`
		Url    string `json:"url"`
		PicUrl string `json:"pic_url"`
	} `json:"link"`
	OpenKfid       string `json:"open_kfid"`
	ExternalUserid string `json:"external_userid"`
}

type MsgEvent

type MsgEvent struct {
	EventType      string `json:"event_type"`
	Scene          string `json:"scene"`
	OpenKfid       string `json:"open_kfid"`
	ExternalUserid string `json:"external_userid"`
	WelcomeCode    string `json:"welcome_code"`
}

type MsgRet

type MsgRet struct {
	Errcode    int    `json:"errcode"`
	ErrMsg     string `json:"errmsg"`
	NextCursor string `json:"next_cursor"`
	MsgList    []Msg  `json:"msg_list"`
}

type ProtocolProcessor

type ProtocolProcessor interface {
	// contains filtered or unexported methods
}

type ProtocolType

type ProtocolType int
const (
	XmlType ProtocolType = 1
)

type ReplyMsg

type ReplyMsg struct {
	Touser   string `json:"touser,omitempty"`
	OpenKfid string `json:"open_kfid,omitempty"`
	MsgId    string `json:"msgid,omitempty"`
	MsgType  string `json:"msgtype,omitempty"`
	Text     struct {
		Content string `json:"content,omitempty"`
	} `json:"text,omitempty"`
}

type WXBizMsg4Recv

type WXBizMsg4Recv struct {
	Tousername string `xml:"ToUserName"`
	Encrypt    string `xml:"Encrypt"`
	Agentid    string `xml:"AgentID"`
}

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

func (*WXBizMsgCrypt) DecryptMsg

func (self *WXBizMsgCrypt) DecryptMsg(msg_signature, timestamp, nonce string, post_data []byte) ([]byte, *CryptError)

func (*WXBizMsgCrypt) EncryptMsg

func (self *WXBizMsgCrypt) EncryptMsg(reply_msg, timestamp, nonce string) ([]byte, *CryptError)

func (*WXBizMsgCrypt) ParsePlainText

func (self *WXBizMsgCrypt) ParsePlainText(plaintext []byte) ([]byte, uint32, []byte, []byte, *CryptError)

func (*WXBizMsgCrypt) VerifyURL

func (self *WXBizMsgCrypt) VerifyURL(msg_signature, timestamp, nonce, echostr string) ([]byte, *CryptError)

type Wechat

type Wechat struct {
	Token          string
	EncodingAESKey string
	CorpId         string
	CorpSecret     string
	// contains filtered or unexported fields
}

func New

func New(token, encodingAesKey, corpId, corpSecret, nextCursor string) *Wechat

func (*Wechat) CheckWeComSign

func (we *Wechat) CheckWeComSign(msgSign, timestamp, nonce, echoStr string) ([]byte, error)

func (*Wechat) DecryptWeComMsg

func (we *Wechat) DecryptWeComMsg(msgSign, timestamp, nonce string, body []byte) (*MsgRet, error)

func (*Wechat) ReplyMessage

func (we *Wechat) ReplyMessage(externalUserId, openKfid, ask, content string) error

type WechatUserMsg

type WechatUserMsg struct {
	ToUserName string `xml:"ToUserName"`
	CreateTime int64  `xml:"CreateTime"`
	MsgType    string `xml:"MsgType"`
	Event      string `xml:"Event"`
	Token      string `xml:"Token"`
	OpenKfId   string `xml:"OpenKfId"`
}

type XmlProcessor

type XmlProcessor struct {
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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