Documentation ¶
Overview ¶
Package pb provides underlying implementation for qy and mp
Package pb provides encrpyt and descrypt for wechat message request and response ¶
Package pb provides functions for handling the received messages.
Index ¶
- func CreateMenu(requestLine string, menuLayout []byte) error
- func DecryptMsg(cipherText, encodingAESKey string) ([]byte, error)
- func EncryptMsg(origData []byte, encodingAESKey string) (string, error)
- func FetchAccessToken(requestLine string) (string, float64, error)
- func GenNonce() string
- func GenSignature(args ...string) string
- func GenTimestamp() int
- func SendMsg(requestLine string, pkg interface{}) error
- type AccessTokenErrorResponse
- type AccessTokenResponse
- type CDATAText
- type MediaID
- type MenuCreateOpResp
- type RecvBaseDataPkg
- type RecvHandler
- type RecvRespBaseDataPkg
- type SendMsgImagePkg
- type SendMsgRespPkg
- type SendMsgTextPkg
- type TextContent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMenu ¶
func DecryptMsg ¶
DecryptMsg is used to descrpyt the encrypted msg from wechat. it returns the origData of the cipherText. cipherText is msg_encrypt. origData = AES_Decrypt(Base64_Decode[cipherText])
func EncryptMsg ¶
EncryptMsg is used to encrpyt the msg being sent to wechat. it returns the cipherText of the origData. cipherText = Base64_Encode(AES_Encrypt [origData])
func FetchAccessToken ¶
FetchAccessToken provides underlying access token fetching implementation.
func GenSignature ¶
func GenTimestamp ¶
func GenTimestamp() int
Types ¶
type AccessTokenErrorResponse ¶
AccessTokenErrorResponse stores the error result of access token fetching.
type AccessTokenResponse ¶
type AccessTokenResponse struct { AccessToken string `json:"access_token"` ExpiresIn float64 `json:"expires_in"` }
AccessTokenResponse stores the normal result of access token fetching.
type CDATAText ¶
type CDATAText struct {
Text string `xml:",innerxml"`
}
CDATAText is a struct whose field won't be seemed as escape sequence when doing xml parsing.
func String2CDATA ¶
type MenuCreateOpResp ¶
type RecvBaseDataPkg ¶
RecvBaseDataPkg is the base msg struct for qy and mp receive message. it contains the fields shared by qy and mp receive message.
type RecvHandler ¶
type RecvHandler interface { Parse(bodyText []byte, signature, timestamp, nonce, encryptType string) (interface{}, error) Response(msg []byte, encryptType string) ([]byte, error) }
RecvHandler is a interface for qy and mp package to implement.
type RecvRespBaseDataPkg ¶
type RecvRespBaseDataPkg struct { XMLName xml.Name `xml:"xml"` ToUserName CDATAText FromUserName CDATAText CreateTime int MsgType CDATAText }
RecvRespBaseDataPkg is the base msg struct for qy and mp receive response message. it contains the fields shared by qy and mp receive response message.
type SendMsgImagePkg ¶
type SendMsgRespPkg ¶
type SendMsgTextPkg ¶
type SendMsgTextPkg struct { ToUser string `json:"touser,omitempty"` MsgType string `json:"msgtype"` Text TextContent `json:"text"` }
type TextContent ¶
type TextContent struct {
Content string `json:"content"`
}