wechat

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitWechat

func InitWechat()

Types

type GetAccessTokenResponse

type GetAccessTokenResponse struct {
	ErrCode      int    `json:"errcode"`
	ErrMsg       string `json:"errmsg"`
	AccessToken  string `json:"access_token"`
	ExpiresIn    int64  `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	OpenID       string `json:"openid"`
	Scope        string `json:"scope"`
	UnionID      string `json:"unionid"`
}

type GetUserInfoResponse

type GetUserInfoResponse struct {
	ErrCode    int      `json:"errcode"`
	ErrMsg     string   `json:"errmsg"`
	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"`
}

type GetWechatOfficialAccoutAccessTokenResponse

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

type GetWechatOfficialAccoutQRCodeResponse

type GetWechatOfficialAccoutQRCodeResponse struct {
	ErrCode       int    `json:"errcode"`
	ErrMsg        string `json:"errmsg"`
	Ticket        string `json:"ticket"`
	ExpireSeconds int64  `json:"expire_seconds"`
	URL           string `json:"url"`
	CreatedAt     int64  `json:"created_at"`
}

type GetWechatOfficialAccoutUserInfoResponse

type GetWechatOfficialAccoutUserInfoResponse struct {
	ErrCode        int    `json:"errcode"`
	ErrMsg         string `json:"errmsg"`
	Subscribe      int    `json:"subscribe"`
	OpenID         string `json:"openid"`
	Language       string `json:"language"`
	SubscribeTime  int64  `json:"subscribe_time"`
	UnionID        string `json:"unionid"`
	Remark         string `json:"remark"`
	GroupID        int    `json:"groupid"`
	TagIDList      []int  `json:"tagid_list"`
	SubscribeScene string `json:"subscribe_scene"`
	QrScene        int    `json:"qr_scene"`
	QrSceneStr     string `json:"qr_scene_str"`
}

type MiniProgramConfig

type MiniProgramConfig struct {
	MiniProgram   *miniprogram.MiniProgram
	MiniAppConfig *ucmodel.WechatConfig
}

func GetMiniProgram

func GetMiniProgram(app string) *MiniProgramConfig

type QRConnectResult

type QRConnectResult struct {
	Response *GetWechatOfficialAccoutQRCodeResponse
	Finished bool
	Success  bool
	Token    string
}

type SendTplMsgRequest

type SendTplMsgRequest struct {
	ToUser      string `json:"touser"`
	TemplateID  string `json:"template_id"`
	Url         string `json:"url"`
	Miniprogram struct {
		AppID    string `json:"appid"`
		PagePath string `json:"pagepath"`
	} `json:"miniprogram"`
	ClientMsgID string                       `json:"client_msg_id"`
	Data        map[string]map[string]string `json:"data"`
}

type SendTplMsgResponse

type SendTplMsgResponse struct {
	ErrCode int    `json:"errcode"`
	ErrMsg  string `json:"errmsg"`
	MsgID   int    `json:"msgid"`
}

type WechatOpenPlatformWeb

type WechatOpenPlatformWeb struct {
	// AppID is the app id of the wechat open platform web
	WechatConfig              *ucmodel.WechatConfig
	AccessToken               map[string]GetAccessTokenResponse
	OfficialAccoutAccessToken *GetWechatOfficialAccoutAccessTokenResponse

	// 存储Token,并且设置过期时间
	QRConnectResult *cache.Cache
	// contains filtered or unexported fields
}

func GetWechatOpenPlatformWeb

func GetWechatOpenPlatformWeb(app string) *WechatOpenPlatformWeb

func NewWechatOpenPlatformWeb

func NewWechatOpenPlatformWeb(wechatConfig *ucmodel.WechatConfig) *WechatOpenPlatformWeb

func (*WechatOpenPlatformWeb) CheckAccessToken

func (w *WechatOpenPlatformWeb) CheckAccessToken(unionID string) bool

校验Token是否有效

func (*WechatOpenPlatformWeb) CheckWechatOfficialAccoutAccessToken

func (w *WechatOpenPlatformWeb) CheckWechatOfficialAccoutAccessToken(accessToken string) bool

校验WechatOfficialAccoutAccessToken是否有效

func (*WechatOpenPlatformWeb) DecryptState

func (w *WechatOpenPlatformWeb) DecryptState(data, nonce string) (string, error)

DecryptState 解密state参数

func (*WechatOpenPlatformWeb) DeleteQRConnectResult

func (w *WechatOpenPlatformWeb) DeleteQRConnectResult(ticket string)

func (*WechatOpenPlatformWeb) EncryptState

func (w *WechatOpenPlatformWeb) EncryptState() (string, error)

将AppName+当前时间戳使用Secret进行加密,作为state参数

func (*WechatOpenPlatformWeb) GetAccessToken

func (w *WechatOpenPlatformWeb) GetAccessToken(code string) (*GetAccessTokenResponse, error)

GetAccessToken get access token by code

func (*WechatOpenPlatformWeb) GetAuthURL

func (w *WechatOpenPlatformWeb) GetAuthURL() (string, error)

GetAuthURL get auth url

func (*WechatOpenPlatformWeb) GetQRConnectResult

func (w *WechatOpenPlatformWeb) GetQRConnectResult(ticket string) *QRConnectResult

func (*WechatOpenPlatformWeb) GetUserInfo

func (w *WechatOpenPlatformWeb) GetUserInfo(unionID string) (*GetUserInfoResponse, error)

获取个人信息

func (*WechatOpenPlatformWeb) GetWechatOfficialAccoutAccessToken

func (w *WechatOpenPlatformWeb) GetWechatOfficialAccoutAccessToken() (*GetWechatOfficialAccoutAccessTokenResponse, error)

func (*WechatOpenPlatformWeb) GetWechatOfficialAccoutQRCode

func (w *WechatOpenPlatformWeb) GetWechatOfficialAccoutQRCode(isTemp bool, expireSeconds int) (*GetWechatOfficialAccoutQRCodeResponse, error)

func (*WechatOpenPlatformWeb) GetWechatOfficialAccoutUserInfo

func (w *WechatOpenPlatformWeb) GetWechatOfficialAccoutUserInfo(openID string) (*GetWechatOfficialAccoutUserInfoResponse, error)

func (*WechatOpenPlatformWeb) RefreshAccessToken

func (w *WechatOpenPlatformWeb) RefreshAccessToken(unionID string) (string, error)

RefreshAccessToken refresh access token

func (*WechatOpenPlatformWeb) SendTplMsg

func (*WechatOpenPlatformWeb) UpdateQRConnectResult

func (w *WechatOpenPlatformWeb) UpdateQRConnectResult(ticket string, finished bool, success bool, token string)

Jump to

Keyboard shortcuts

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