wechat

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EncryptTypeAES = "aes"
	EncryptTypeRAW = "raw"
)
View Source
const (
	WeiXinSubscribeEvent   = "subscribe"
	WeiXinUnsubscribeEvent = "unsubscribe"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CDATA

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

func Value

func Value(val string) CDATA

type EncryptRequestBody

type EncryptRequestBody struct {
	XMLName    xml.Name `xml:"xml"`
	ToUserName string
	Encrypt    string
}

type EncryptResponseBody

type EncryptResponseBody struct {
	XMLName      xml.Name `xml:"xml"`
	Encrypt      CDATA
	MsgSignature CDATA
	TimeStamp    string
	Nonce        CDATA
}

type PassiveUserReplyMessage

type PassiveUserReplyMessage struct {
	XMLName      xml.Name `xml:"xml"`
	ToUserName   CDATA    `xml:"ToUserName"`
	FromUserName CDATA    `xml:"FromUserName"`
	CreateTime   CDATA    `xml:"CreateTime"`
	MsgType      CDATA    `xml:"MsgType"`
	Content      CDATA    `xml:"Content"`
}

func (*PassiveUserReplyMessage) String

func (p *PassiveUserReplyMessage) String() string

type TextRequestBody

type TextRequestBody struct {
	XMLName      xml.Name `xml:"xml"`
	ToUserName   string
	FromUserName string
	CreateTime   time.Duration
	MsgType      string
	Content      string
	MsgId        int
	Event        string
}

type WeiXin

type WeiXin struct {
	// contains filtered or unexported fields
}

func NewWeiXin

func NewWeiXin(appid, token, key string) *WeiXin

func (*WeiXin) EncodingAESKey2AESKey

func (w *WeiXin) EncodingAESKey2AESKey() []byte

func (*WeiXin) MakeEncryptResponseBody

func (w *WeiXin) MakeEncryptResponseBody(fromUserName, toUserName, content, nonce, timestamp string) ([]byte, error)

func (*WeiXin) MakeEncryptXmlData

func (w *WeiXin) MakeEncryptXmlData(fromUserName, toUserName, timestamp, content string) (string, error)

func (*WeiXin) MakeMsgSignature

func (w *WeiXin) MakeMsgSignature(timestamp, nonce, msgEncrypt string) string

func (*WeiXin) MakeSignature

func (w *WeiXin) MakeSignature(timestamp, nonce string) string

func (*WeiXin) PKCS7Pad

func (w *WeiXin) PKCS7Pad(message []byte, blockSize int) (padded []byte)

func (*WeiXin) PadLength

func (w *WeiXin) PadLength(sliceLength, blockSize int) (padLen int)

func (*WeiXin) ParseEncryptRequestBody

func (w *WeiXin) ParseEncryptRequestBody(timestamp, nonce, msgSignature string, rawBody []byte) (*TextRequestBody, error)

func (*WeiXin) ParseEncryptTextRequestBody

func (w *WeiXin) ParseEncryptTextRequestBody(plainText []byte) (*EncryptRequestBody, error)

func (*WeiXin) ValidateAppId

func (w *WeiXin) ValidateAppId(id []byte) bool

func (*WeiXin) ValidateMsg

func (w *WeiXin) ValidateMsg(timestamp, nonce, msgEncrypt, msgSignatureIn string) bool

type WeiXinMsgType

type WeiXinMsgType string
const (
	WeiXinTextMsgType  WeiXinMsgType = "text"
	WeiXinImageMsgType WeiXinMsgType = "image"
	WeiXinVoiceMsgType WeiXinMsgType = "voice"
	WeiXinVideoMsgType WeiXinMsgType = "video"
	WeiXinMusicMsgType WeiXinMsgType = "music"
	WeiXinNewsMsgType  WeiXinMsgType = "news"
	WeiXinEventMsgType WeiXinMsgType = "event"
)

Jump to

Keyboard shortcuts

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