wechat

package
v0.0.0-...-a91bc6d Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Prefix                   = "wechat"
	PrefixApp                = "wechat/app"
	PrefixAccessToken        = "wechat/accesstoken"
	PrefixRefreshAccessToken = "wechat/refreshaccesstoken"
	PrefixAccessAt           = "wechat/accessat"

	PrefixLock = "lock"

	StateNormal          = 0 // 正常
	StateInvalid         = 1 // 上报失效. 不能使用
	StateNeedRefresh     = 2
	StateUpdatedDirectly = 3 // 手动更新的,更新检测版本
)

Variables

View Source
var (
	ErrAppNotFound = errors.New("app not found")
)

Functions

func AESDecryptMsg

func AESDecryptMsg(ciphertext []byte, aesKey []byte) (random, rawXMLMsg, appID []byte, err error)

AESDecryptMsg ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId] 参考:github.com/chanxuehong/wechat.v2

func AESEncryptMsg

func AESEncryptMsg(random, rawXMLMsg []byte, appID string, aesKey []byte) (ciphertext []byte)

AESEncryptMsg ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId] 参考:github.com/chanxuehong/wechat.v2

func DecryptMsg

func DecryptMsg(appID, encryptedMsg, aesKey string) (random, rawMsgXMLBytes []byte, err error)

DecryptMsg 消息解密

func EncryptMsg

func EncryptMsg(random, rawXMLMsg []byte, appID, aesKey string) (encrtptMsg []byte, err error)

func GetKey

func GetKey(parts ...string) string

func MD5Sum

func MD5Sum(txt string) (sum string)

MD5Sum 计算 32 位长度的 MD5 sum

func RandomStr

func RandomStr(length int) string

func Signature

func Signature(params ...string) string

Types

type AccessToken

type AccessToken struct {
	AppId       string `json:"appId,omitempty"`
	AccessToken string `json:"accessToken,omitempty"`
	Rev         int64  `json:"-"`
	State       int    `json:"-"`
	ExpiresAt   int64  `json:"expiresAt,omitempty"`
}

func (*AccessToken) Clone

func (this *AccessToken) Clone() *AccessToken

func (*AccessToken) Decode

func (this *AccessToken) Decode(b []byte) error

func (*AccessToken) Encode

func (this *AccessToken) Encode() []byte

func (*AccessToken) IsInvalid

func (this *AccessToken) IsInvalid() bool

func (*AccessToken) IsNeedRefresh

func (this *AccessToken) IsNeedRefresh() bool

type AccessTokenAccessAt

type AccessTokenAccessAt struct {
	AppId    string
	AccessAt int64
}

func (*AccessTokenAccessAt) Decode

func (this *AccessTokenAccessAt) Decode(b []byte) error

func (*AccessTokenAccessAt) Encode

func (this *AccessTokenAccessAt) Encode() []byte

type App

type App struct {
	AppId  string `json:"appId,omitempty"`
	Secret string `json:"secret,omitempty"`
}

func (*App) Decode

func (this *App) Decode(b []byte) error

func (*App) Encode

func (this *App) Encode() []byte

type CheckUserAccessTokenArg

type CheckUserAccessTokenArg = api.CheckUserAccessTokenArg

type CheckUserAccessTokenReply

type CheckUserAccessTokenReply = api.CheckUserAccessTokenReply

type Config

type Config struct {
	ApiDomain                 string           `json:"apiDomain,omitempty"`
	AccessAtUpdateTime        int64            `json:"accessAtUpdateTime,omitempty"`
	DropAccessTokenNotUseTime int64            `json:"dropAccessTokenNotUseTime,omitempty"`
	EtcdCliName               string           `json:"etcdCliName,omitempty"`
	RestyCliName              string           `json:"restyCliName,omitempty"`
	Logger                    *logrus.Logger   `json:"-"`
	EtcdCli                   *clientv3.Client `json:"-"`
	RestyCli                  *resty.Client    `json:"-"`
}

type CreateAppArg

type CreateAppArg = App

type CreateAppReply

type CreateAppReply struct{}

type DeleteAppArg

type DeleteAppArg struct {
	AppId string
}

type DeleteAppReply

type DeleteAppReply struct{}

type GetAccessTokenArg

type GetAccessTokenArg struct {
	AppId              string `json:"appId"`
	CompareAccessToken string `json:"compareAccessToken"`
}

type GetAccessTokenReply

type GetAccessTokenReply = AccessToken

type GetAppArg

type GetAppArg struct {
	AppId string
}

type GetAppReply

type GetAppReply = App

type GetAuthUrlArg

type GetAuthUrlArg = api.GetAuthUrlArg

type GetAuthUrlReply

type GetAuthUrlReply = api.GetAuthUrlReply

type GetUserAccessTokenArg

type GetUserAccessTokenArg = api.GetUserAccessTokenArg

type GetUserAccessTokenReply

type GetUserAccessTokenReply = api.GetUserAccessTokenReply

type GetUserInfoArg

type GetUserInfoArg = api.GetUserInfoArg

type GetUserInfoReply

type GetUserInfoReply = api.GetUserInfoReply

type RefreshAccessToken

type RefreshAccessToken struct {
	AppId           string
	LastAccessToken string
}

func (*RefreshAccessToken) Decode

func (this *RefreshAccessToken) Decode(b []byte) error

func (*RefreshAccessToken) Encode

func (this *RefreshAccessToken) Encode() []byte

type RefreshUserAccessTokenArg

type RefreshUserAccessTokenArg = api.RefreshUserAccessTokenArg

type RefreshUserAccessTokenReply

type RefreshUserAccessTokenReply = api.RefreshUserAccessTokenReply

type UpdateAppArg

type UpdateAppArg = App

type UpdateAppReply

type UpdateAppReply struct{}

type Wechat

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

func New

func New(cfg *Config) (*Wechat, error)

func (*Wechat) CheckUserAccessToken

func (this *Wechat) CheckUserAccessToken(arg *CheckUserAccessTokenArg) (reply *CheckUserAccessTokenReply, err error)

func (*Wechat) Close

func (this *Wechat) Close() error

func (*Wechat) CreateApp

func (this *Wechat) CreateApp(arg *CreateAppArg) (*CreateAppReply, error)

func (*Wechat) DeleteApp

func (this *Wechat) DeleteApp(arg *DeleteAppArg) (*DeleteAppReply, error)

func (*Wechat) GetAccessToken

func (this *Wechat) GetAccessToken(arg *GetAccessTokenArg) (*GetAccessTokenReply, error)

func (*Wechat) GetApp

func (this *Wechat) GetApp(arg *GetAppArg) (*GetAppReply, error)

func (*Wechat) GetAuthUrl

func (this *Wechat) GetAuthUrl(arg *GetAuthUrlArg) (*GetAuthUrlReply, error)

func (*Wechat) GetUserAccessToken

func (this *Wechat) GetUserAccessToken(arg *GetUserAccessTokenArg) (reply *GetUserAccessTokenReply, err error)

func (*Wechat) GetUserInfo

func (this *Wechat) GetUserInfo(arg *GetUserInfoArg) (reply *GetUserInfoReply, err error)

func (*Wechat) RefreshUserAccessToken

func (this *Wechat) RefreshUserAccessToken(arg *RefreshUserAccessTokenArg) (reply *RefreshUserAccessTokenReply, err error)

func (*Wechat) UpdateApp

func (this *Wechat) UpdateApp(arg *UpdateAppArg) (*UpdateAppReply, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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