mpwechat

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APIURL = `https://api.weixin.qq.com/sns/jscode2session`

Functions

This section is empty.

Types

type Response

type Response struct {
	// 错误时结果
	ErrCode int64  `json:"errcode,omitempty" xml:"errcode,omitempty"`
	ErrMsg  string `json:"errmsg,omitempty" xml:"errmsg,omitempty"`

	// 正常时结果
	UnionID    string `json:"unionid,omitempty" xml:"unionid,omitempty"`
	ExpiresIn  int64  `json:"expires_in,omitempty" xml:"expires_in,omitempty"`   //凭证有效时间,单位:秒
	OpenID     string `json:"openid,omitempty" xml:"openid,omitempty"`           //用户唯一标识
	SessionKey string `json:"session_key,omitempty" xml:"session_key,omitempty"` //会话密匙(考虑到应用安全,不应该在网络上传输session_key)
}

func (*Response) AsUser

func (result *Response) AsUser(post *WechatPostData) *goth.User

type WechatAuthResult

type WechatAuthResult struct {
	AccessToken  string `json:"access_token"`  //: "39_pW95pgvNPYWl6cwnTa_****************************************************-mw0cpC85m1AJ16HCsh0O-Z-ZVDigLsoJGFQ",
	Code         string `json:"code"`          //: "0232DTkl2F2j564O5qnl2TAhdO32DTkq",
	ExpiresIn    int64  `json:"expires_in"`    //: 7200,
	OpenID       string `json:"openid"`        //: "oRrdQt8*************QvsqGu_U",
	RefreshToken string `json:"refresh_token"` //: "39_H4WOg6FqOtktcLSiwclqYaNEoDnnUA-jPPfCx769isAstsp77Z64U7FFy5Com8dqN58iqWnilZgF0lyDU16lEn8_Ti89UaU_*******-***",
	Scope        string `json:"scope"`         //: "snsapi_userinfo",
	UnionID      string `json:"unionid"`       //: "oU5Yyt48Fmo*********_HR5D0vc"
}

type WechatPostData

type WechatPostData struct {
	AuthResult *WechatAuthResult `json:"authResult"`
	UserInfo   *WechatUserInfo   `json:"userInfo"`
}

func NewWechatPostData

func NewWechatPostData() *WechatPostData

func (*WechatPostData) Check

func (post *WechatPostData) Check(ctx echo.Context) error

func (*WechatPostData) Post

func (post *WechatPostData) Post(ctx echo.Context, appID string, appSecret string) (*Response, error)

type WechatUserInfo

type WechatUserInfo struct {
	OpenID    string `json:"openId"`    //: "oRrdQt8*************QvsqGu_U",
	NickName  string `json:"nickName"`  //: "辉煌",
	Gender    string `json:"gender"`    //: 1,
	City      string `json:"city"`      //: "Guangzhou",
	Province  string `json:"province"`  //: "Guangdong",
	Country   string `json:"country"`   //: "China",
	AvatarURL string `json:"avatarUrl"` //: "https://thirdwx.qlogo.cn/mmopen/vi_32/PWLwicVtiaRhHQNTDpGIh9iauwCPQ4uI7H1Q2nGoicSd4VTxqoMjmBhjdPO1YzFlFic6RkUFmGM54k6I2gaNGIGwGMg/132",
	UnionID   string `json:"unionId"`   //: "oU5Yyt48Fmo*********_HR5D0vc"
}

func (*WechatUserInfo) Location

func (u *WechatUserInfo) Location() string

Jump to

Keyboard shortcuts

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