wxcom

package
v0.0.0-...-849f898 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesCbcDecryption

func AesCbcDecryption(key, iv, cipherText []byte) ([]byte, error)

func PKCS7UnPadding

func PKCS7UnPadding(data []byte) []byte

Types

type AccessTokenInfo

type AccessTokenInfo struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int64  `json:"expires_in"`
}

AccessTokenInfo access token info

func FetchAccessTokenPubAcc

func FetchAccessTokenPubAcc(appID, appSecret string) (*AccessTokenInfo, error)

FetchAccessTokenPubAcc get access token for public account

url: https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_access_token.html

type CommonUserInfo

type CommonUserInfo struct {
	OpenID     string   `json:"openid"` //用户的标识,对当前公众号唯一
	NickName   string   `json:"nickname"`
	Sex        int8     `json:"sex"`
	Province   string   `json:"province"`
	City       string   `json:"city"`
	Country    string   `json:"country"`
	HeadImgURL string   `json:"head_img_url"`
	UnionID    string   `json:"unionid"`
	Privilege  []string `json:"privilege"`
}

CommonUserInfo user info

func FetchUserInfo

func FetchUserInfo(openid, accessToken string) (*CommonUserInfo, error)

FetchUserInfo 获取用户信息

url: https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html

type Oauth2Rst

type Oauth2Rst struct {
	AccessTokenInfo
	SessionKey   string `json:"session_key"`
	OpenID       string `json:"openid"`
	UnionID      string `json:"unionid"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
	Errcode      int    `json:"errcode"`
	Errmsg       string `json:"errmsg"`
}

Oauth2Rst wx oauth2 result

func Oauth2WxApp

func Oauth2WxApp(appID, appSecret, code string) (*Oauth2Rst, error)

Oauth2WxApp transfrom code to access_token

func Oauth2WxH5

func Oauth2WxH5(appID, appSecret, code string) (*Oauth2Rst, error)

Oauth2WxH5 transfrom code to access_token

func Oauth2WxMiniApp

func Oauth2WxMiniApp(appID, appSecret, jsCode string) (*Oauth2Rst, error)

Oauth2WxMiniApp authorize client's js_code when miniapp login. if success, we can get openid, etc.

url: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html

type PubAccountUserInfo

type PubAccountUserInfo struct {
	CommonUserInfo
	Subscribe      int8   `json:"subscribe"` //是否订阅该公众号标识
	Language       string `json:"language"`
	SubscribeTime  int64  `json:"subscribe_time"`
	Remark         string `json:"remark"`
	GroupID        int    `json:"groupid"`
	SubscribeScene string `json:"subscribe_scene"`
	QrScene        int    `json:"qr_scene"`
	QrSceneStr     string `json:"qr_scene_str"`
}

PubAccountUserInfo public account用户信息定义

UserInfoResponse https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839 字段说明

func FetchPubAccUserInfo

func FetchPubAccUserInfo(openid, accessToken string) (*PubAccountUserInfo, error)

FetchPubAccUserInfo 获取public account用户信息

获取wx_AccessToken 拼接get请求 解析返回json结果 返回 AccessToken和err
url: https://developers.weixin.qq.com/doc/offiaccount/User_Management/Get_users_basic_information_UnionID.html

type WxUserInfoDE

type WxUserInfoDE struct {
	OpenID    string               `json:"openId"`
	NickName  string               `json:"nickName"`
	Gender    int                  `json:"gender"`
	Language  string               `json:"language"`
	City      string               `json:"city"`
	Province  string               `json:"province"`
	Country   string               `json:"country"`
	AvatarURL string               `json:"avatarUrl"`
	UnionID   string               `json:"unionId"`
	Watermark *WxUserInfoWatermark `json:"watermark"`
}

func DecryptWxUserInfo

func DecryptWxUserInfo(encryptedData, iv, sessionKey string) (*WxUserInfoDE, error)

* * support: * when login with jscode (miniprogram), client get rawData of userinfo firstly, then server need to decrypt it * notes: * need client get rawData firstly *

type WxUserInfoWatermark

type WxUserInfoWatermark struct {
	AppID     string `json:"appid"`
	Timestamp int    `json:"timestamp"`
}

Jump to

Keyboard shortcuts

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