Documentation ¶
Index ¶
- func PKCS7UnPadding(plantText []byte) []byte
- type AccessData
- type AppletClient
- func (c *AppletClient) CodeToSession(code string) (sessionData *WxAppletSessionData, err error)
- func (c *AppletClient) Decrypt(sessionKey, encryptedData string, iv string) (*WxAppletUserInfo, error)
- func (c *AppletClient) DecryptPhoneInfo(sessionKey, encryptedData string, iv string) (*WxAppletPhoneInfo, error)
- func (c *AppletClient) GetAccessToken() (accessTokenData *WxAppletAccessToken, err error)
- func (c *AppletClient) GetUserPhoneNumber(accessToken, code string) (phoneNumber string, err error)
- type Client
- func (c *Client) CodeToAccessToken(code string) (accessData *AccessData, err error)
- func (c *Client) GetJSAPIConfig(ticket, url string) (data *JSWXConfig, err error)
- func (c *Client) GetJSAPITicket(mpGlobalToken string) (ticketData *TicketData, err error)
- func (c *Client) GetMpGlobalToken() (mpTokenData *MpTokenData, err error)
- func (c *Client) GetPayConfig(payParam string) (payConfig *PayConfig, err error)
- func (c *Client) GetWxUser(accessToken, openid string) (wxUser *WxUser, err error)
- func (c *Client) SetApiKey(apiKey string)
- type CodeReq
- type JSWXConfig
- type MpTokenData
- type PayConfig
- type PhoneInfo
- type TicketData
- type WxAppletAccessToken
- type WxAppletGetUserPhoneNumberResp
- type WxAppletPhoneInfo
- type WxAppletSessionData
- type WxAppletUserInfo
- type WxUser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PKCS7UnPadding ¶
PKCS7UnPadding return unpadding []Byte plantText
Types ¶
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 ¶
AppletClient Client
func NewAppletClient ¶
func NewAppletClient(appId, secret string) *AppletClient
NewAppletClient 传入appId和appSecret
func (*AppletClient) CodeToSession ¶
func (c *AppletClient) CodeToSession(code string) (sessionData *WxAppletSessionData, err error)
CodeToSession 根据code值换session
func (*AppletClient) Decrypt ¶
func (c *AppletClient) Decrypt(sessionKey, encryptedData string, iv string) (*WxAppletUserInfo, error)
Decrypt decrypt user info
func (*AppletClient) DecryptPhoneInfo ¶
func (c *AppletClient) DecryptPhoneInfo(sessionKey, encryptedData string, iv string) (*WxAppletPhoneInfo, error)
DecryptPhoneInfo decrypt phone
func (*AppletClient) GetAccessToken ¶
func (c *AppletClient) GetAccessToken() (accessTokenData *WxAppletAccessToken, err error)
GetAccessToken accessToken
func (*AppletClient) GetUserPhoneNumber ¶ added in v1.3.4
func (c *AppletClient) GetUserPhoneNumber(accessToken, code string) (phoneNumber string, err error)
type Client ¶
Client Client
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
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 ¶
type WxAppletAccessToken struct { AccessToken string `json:"access_token"` ExpiresIn int `json:"expires_in"` ErrCode int `json:"errcode"` ErrMsg string `json:"errmsg"` }
WxAppletAccessToken applet access token
type WxAppletGetUserPhoneNumberResp ¶ added in v1.3.4
type WxAppletGetUserPhoneNumberResp struct { ErrCode int `json:"errcode"` ErrMsg string `json:"errmsg"` PhoneInfo *PhoneInfo `json:"phone_info"` }
WxAppletGetUserPhoneNumberResp 新版本新方法 获取微信用户电话号码
type WxAppletPhoneInfo ¶
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"` }
WxAppletPhoneInfo 微信小程序用户电话号码信息
type WxAppletSessionData ¶
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 ¶
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"` }
WxAppletUserInfo 微信小程序用户基础信息
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 微信的获取用户信息