mxlogin

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReturnErrCodeKey = "errcode"
	ReturnErrMsgKey  = "errmsg"
	ReturnOpenIDKey  = "openid"
	ReturnSessionKey = "session_key"
)

Variables

View Source
var (
	ErrLoginParamError    = errors.New("wxLogin param error")
	ErrEncryptedDataError = errors.New("encryptedData errors")
)

Functions

func NewWXDataCrypt

func NewWXDataCrypt(appId string, sessionKey string) *wxDataCrypt

Types

type EncryptedData

type EncryptedData struct {
	OpenId    string `json:"openId"`
	NickName  string `json:"nickName"`
	Gender    byte   `json:"gender"`
	City      string `json:"city"`
	Province  string `json:"province"`
	Country   string `json:"country"`
	AvatarUrl string `json:"avatarUrl"`
	UnionId   string `json:"unionId"`
}

加密数据

type UserInfo

type UserInfo struct {
	NickName  string `json:"nickName"`
	Gender    byte   `json:"gender"`
	City      string `json:"city"`
	Province  string `json:"province"`
	Country   string `json:"country"`
	Language  string `json:"language"`
	AvatarUrl string `json:"avatarUrl"`
}

微信用户信息

type WXAuthorization

type WXAuthorization struct {
	Openid     string `json:"openid"`      //用户唯一标识
	SessionKey string `json:"session_key"` //会话密钥
	Unionid    string `json:"unionid"`     //用户在开放平台的唯一标识符。
	Errcode    int    `json:"errcode"`     //错误码
	ErrMsg     string `json:"errmsg"`      //错误信息
}

type WXLogin

type WXLogin struct {
	AppId     string
	AppSecret string
}

func New

func New(appId, appSecret string) (wx *WXLogin, err error)

func (*WXLogin) Check

func (wx *WXLogin) Check(rawData, signature, session_key string) bool

微信数据签名校验

func (*WXLogin) Code2Session

func (wx *WXLogin) Code2Session(code string) (wxa *WXAuthorization, err error)

临时登录凭证code

func (*WXLogin) DecryptPhoneNumber

func (wx *WXLogin) DecryptPhoneNumber(encryptedData, iv, sessionKey string) (wpn *WXPhoneNumber, err error)

加密数据( encryptedData )进行解密

func (*WXLogin) DecryptUserInfo

func (wx *WXLogin) DecryptUserInfo(encryptedData, iv, sessionKey string) (wxu *EncryptedData, err error)

用户信息加密数据( encryptedData )进行解密

func (*WXLogin) GetUserInfo

func (wx *WXLogin) GetUserInfo(accessToken, openid string) (wxu *EncryptedData, err error)

func (*WXLogin) Login

func (wx *WXLogin) Login(encryptedData, iv, code string) (wxu *WXUserInfo, err error)

微信登录 加密数据( encryptedData )进行解密

type WXPhoneNumber

type WXPhoneNumber struct {
	PhoneNumber     string `json:"phoneNumber"`     //用户绑定的手机号(国外手机号会有区号)
	PurePhoneNumber string `json:"purePhoneNumber"` //没有区号的手机号
	CountryCode     string `json:"countryCode"`     //区号
}

type WXUserInfo

type WXUserInfo struct {
	Userinfo   EncryptedData `json:"userinfo"`
	SessionKey string        `json:"skey"` //会话密钥
}

Jump to

Keyboard shortcuts

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