v0.6.8 Latest Latest

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

Go to latest
Published: Aug 17, 2021 License: MIT Imports: 11 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type AccessData

type AccessData struct {
	AccessType   int64  `json:"access_type"`
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Openid       string `json:"openid"`
	Scope        string `json:"scope"`
	Unionid      string `json:"unionid"`
	ErrCode      int    `json:"errcode"`
	ErrMsg       string `json:"errmsg"`

AccessData AccessData

type AppletClient added in v0.4.2

type AppletClient struct {
	AppId  string
	Secret string

AppletClient Client

func NewAppletClient added in v0.4.2

func NewAppletClient(appId, secret string) *AppletClient

NewAppletClient 传入appId和appSecret

func (*AppletClient) CodeToSession added in v0.4.2

func (c *AppletClient) CodeToSession(code string) (sessionData *WxAppletSessionData, err error)

CodeToSession 根据code值换session

func (*AppletClient) Decrypt added in v0.4.2

func (c *AppletClient) Decrypt(sessionKey, encryptedData string, iv string) (*WxAppletUserInfo, error)

func (*AppletClient) DecryptPhoneInfo added in v0.6.0

func (c *AppletClient) DecryptPhoneInfo(sessionKey, encryptedData string, iv string) (*WxAppletPhoneInfo, error)

func (*AppletClient) GetAccessToken added in v0.4.2

func (c *AppletClient) GetAccessToken() (accessTokenData *WxAppletAccessToken, err error)

GetAccessToken accessToken

type Client

type Client struct {
	AppId  string
	Secret string
	ApiKey string //仅支付时需要

Client Client

func NewClient

func NewClient(appId, secret string) *Client

NewClient NewClient 传入appId和appSecret

func (*Client) CodeToAccessToken

func (c *Client) CodeToAccessToken(code string) (accessData *AccessData, err error)

CodeToAccessToken 根据code值换行accessToken 第一步

func (*Client) GetJSAPIConfig

func (c *Client) GetJSAPIConfig(ticket, url string) (data *JSWXConfig, err error)

GetJSAPIConfig 获取微信公众号js sdk api 的配置信息 输出到H5页面 ticket为暂存的ticket值 url为H5页面的完整地址

func (*Client) GetJSAPITicket

func (c *Client) GetJSAPITicket(mpGlobalToken string) (ticketData *TicketData, err error)

GetJSAPITicket 根据全局token,获取ticket 返回的ticket需要存放起来,过期时间通常为:7200

func (*Client) GetMpGlobalToken

func (c *Client) GetMpGlobalToken() (mpTokenData *MpTokenData, err error)

GetMpGlobalToken 获取微信公众号的全局token expiresIn:过期时间 此值返回后,需要存放起来,过期时间通常为:7200

func (*Client) GetPayConfig

func (c *Client) GetPayConfig(payParam string) (payConfig *PayConfig, err error)

GetPayConfig 获取公众号支付时的参数


func (*Client) GetWxUser

func (c *Client) GetWxUser(accessToken, openid string) (wxUser *WxUser, err error)

GetWxUser 根据accessToken和openid获取用户的基本信息 第二步

func (*Client) SetApiKey

func (c *Client) SetApiKey(apiKey string)

SetApiKey 公众号支付时,必须设置此值

type JSWXConfig

type JSWXConfig struct {
	Debug     bool     `json:"debug"`
	AppID     string   `json:"appId"`
	TimeStamp int64    `json:"timestamp"`
	NonceStr  string   `json:"nonceStr"`
	Signature string   `json:"signature"`
	JsAPIList []string `json:"jsApiList"`

JSWXConfig 公众号开发模式下,H5需要使用的JSWXConfig

type MpTokenData

type MpTokenData struct {
	ErrCode     int    `json:"errcode"`
	ErrMsg      string `json:"errmsg"`
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`

MpTokenData 微信公众号的全局token

type PayConfig

type PayConfig struct {
	AppID     string `json:"appId"`
	TimeStamp int64  `json:"timeStamp"`
	NonceStr  string `json:"nonceStr"`
	Package   string `json:"package"`
	SignType  string `json:"signType"`
	PaySign   string `json:"paySign"`

PayConfig 公众号支付时pay参数配置

type TicketData

type TicketData struct {
	ErrCode   int    `json:"errcode"`
	ErrMsg    string `json:"errmsg"`
	Ticket    string `json:"ticket"`
	ExpiresIn int    `json:"expires_in"`

TicketData ticket返回值

type WxAppletAccessToken added in v0.4.2

type WxAppletAccessToken struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
	ErrCode     int    `json:"errcode"`
	ErrMsg      string `json:"errmsg"`

type WxAppletPhoneInfo added in v0.6.0

type WxAppletPhoneInfo struct {
	PhoneNumber     string `json:"phoneNumber"`
	PurePhoneNumber string `json:"purePhoneNumber"`
	CountryCode     string `json:"countryCode"`
	Watermark       struct {
		Timestamp int64  `json:"timestamp"`
		AppID     string `json:"appid"`
	} `json:"watermark"`


type WxAppletSessionData added in v0.4.2

type WxAppletSessionData struct {
	Openid     string `json:"openid"`
	SessionKey string `json:"session_key"`
	Unionid    string `json:"unionid"`
	ErrCode    int    `json:"errcode"`
	ErrMsg     string `json:"errmsg"`

WxAppletSessionData 微信小程序

type WxAppletUserInfo added in v0.4.2

type WxAppletUserInfo struct {
	OpenID    string `json:"openId"`
	UnionID   string `json:"unionId"`
	NickName  string `json:"nickName"`
	Gender    int    `json:"gender"`
	City      string `json:"city"`
	Province  string `json:"province"`
	Country   string `json:"country"`
	AvatarURL string `json:"avatarUrl"`
	Language  string `json:"language"`
	Watermark struct {
		Timestamp int64  `json:"timestamp"`
		AppID     string `json:"appid"`
	} `json:"watermark"`


type WxUser

type WxUser struct {
	Openid     string   `json:"openid"`
	Nickname   string   `json:"nickname"`
	Sex        int      `json:"sex"`
	Province   string   `json:"province"`
	City       string   `json:"city"`
	Country    string   `json:"country"`
	Headimgurl string   `json:"headimgurl"`
	Privilege  []string `json:"privilege"`
	Unionid    string   `json:"unionid"`
	ErrCode    int      `json:"errcode"`
	ErrMsg     string   `json:"errmsg"`

WxUser 微信的获取用户信息

Jump to

Keyboard shortcuts

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