pb

package
v0.0.0-...-125b544 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2015 License: Apache-2.0 Imports: 17 Imported by: 0

README

lower and "public"(pb) functions for qy and mp

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMenu

func CreateMenu(requestLine string, menuLayout []byte) error

func DecryptMsg

func DecryptMsg(cipherText, encodingAESKey string) ([]byte, error)

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

func EncryptMsg(origData []byte, encodingAESKey string) (string, error)

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

func FetchAccessToken(requestLine string) (string, float64, error)

FetchAccessToken provides underlying access token fetching implementation.

func GenNonce

func GenNonce() string

func GenSignature

func GenSignature(args ...string) string

func GenTimestamp

func GenTimestamp() int

func SendMsg

func SendMsg(requestLine string, pkg interface{}) error

Types

type AccessTokenErrorResponse

type AccessTokenErrorResponse struct {
	Errcode string
	Errmsg  string
}

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

func String2CDATA(v string) CDATAText

type MediaID

type MediaID struct {
	MediaID string `json:"media_id"`
}
type MenuCreateOpResp struct {
	Errcode int
	Errmsg  string
}

type RecvBaseDataPkg

type RecvBaseDataPkg struct {
	ToUserName   string
	FromUserName string
	CreateTime   int
	MsgType      string
}

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 SendMsgImagePkg struct {
	ToUser  string  `json:"touser, omitempty"`
	MsgType string  `json:"msgtype"`
	Image   MediaID `json:"image"`
}

type SendMsgRespPkg

type SendMsgRespPkg struct {
	Errcode int    `json:"errcode"`
	Errmsg  string `json:"errmsg"`
}

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"`
}

Jump to

Keyboard shortcuts

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