Documentation ¶
Index ¶
- type ActionInfo
- type AppAccessToken
- type Client
- func (c *Client) GetAppAccessToken() error
- func (c *Client) GetAppAccessTokenUrl() string
- func (c *Client) GetAuthorizeURL(state string) string
- func (c *Client) GetQRTicket(codeType string, sceneId int) (string, error)
- func (c *Client) GetQrTicketURL(appAccessToken string) string
- func (c *Client) GetUserAccessToken(code string) (*GetUserAccessTokenRes, string, error)
- func (c *Client) GetUserAccessTokenUrl(code string) string
- func (c *Client) GetUserInfo(accessToken *GetUserAccessTokenRes, openid string) (*GetUserInfoRes, error)
- func (c *Client) GetUserInfoUrl(accessToken, openid string) string
- func (c *Client) GetVaildAppAccessToken() (at string, err error)
- func (c *Client) RefreshAppAccessToken() error
- func (c *Client) VerifySignature(vp VerifyParams) bool
- type GetQRTicketReq
- type GetQRTicketRes
- type GetUserAccessTokenRes
- type GetUserInfoRes
- type Scene
- type UserEvent
- type VerifyParams
- type WechatCfg
- type WechatLangType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionInfo ¶
type ActionInfo struct {
Scene `json:"scene"`
}
type AppAccessToken ¶
type AppAccessToken struct { AccessToken string `json:"access_token"` ExpiresTime int `json:"expires_in"` Time time.Time }
应用的access token
type Client ¶
type Client struct { // 应用appID AppID string // 应用appSecret AppSecret string // 应用配置的token AppToken string // 授权成功后微信回调接口 RedirectURL string // 二维码有效时长s QrValidTime int AppAccessToken *AppAccessToken // 获取应用授权token url AppAccessTokenURL string // 获取二维码ticket url QrTicketURL string // 用户授权url UserAuthorizeURL string // 获取用户授权token url UserAccessTokenURL string // 获取用户信息url UserInfoURL string Lang WechatLangType // 请求资源范围,多个空格隔开 Scopes string // contains filtered or unexported fields }
func New ¶
func New(appID, appSecret, appToken, redirectURL string, qrValidTime int, lang WechatLangType) *Client
New creates a new Wechat Login Client
func (*Client) GetAppAccessTokenUrl ¶
func (*Client) GetAuthorizeURL ¶
func (*Client) GetQRTicket ¶
func (*Client) GetQrTicketURL ¶
func (*Client) GetUserAccessToken ¶
func (c *Client) GetUserAccessToken(code string) (*GetUserAccessTokenRes, string, error)
GetUserAccessToken will go to Wepay and access access token about the user.
func (*Client) GetUserAccessTokenUrl ¶
func (*Client) GetUserInfo ¶
func (c *Client) GetUserInfo(accessToken *GetUserAccessTokenRes, openid string) (*GetUserInfoRes, error)
GetUserInfo will go to Wepay and access basic information about the user.
func (*Client) GetUserInfoUrl ¶
func (*Client) GetVaildAppAccessToken ¶
GetVaildAppAccessToken 获取应用accesstoken
func (*Client) RefreshAppAccessToken ¶
AppAccessToken 刷新应用AccessToken
type GetQRTicketReq ¶
type GetQRTicketReq struct { ExpireSeconds int `json:"expire_seconds"` ActionName string `json:"action_name"` ActionInfo ActionInfo `json:"action_info"` }
QR code 请求体
type GetQRTicketRes ¶
type GetQRTicketRes struct { Ticket string `json:"ticket"` ExpireSeconds int `json:"expire_seconds"` Url string `json:"url"` }
QR code 响应体
type GetUserAccessTokenRes ¶
type GetUserAccessTokenRes struct { AccessToken string `json:"access_token"` ExpiresIn time.Duration `json:"expires_in"` RefreshToken string `json:"refresh_token"` Openid string `json:"openid"` Scope string `json:"scope"` IsSnapshotuser int `json:"is_snapshotuser"` Unionid string `json:"unionid"` Code int `json:"errcode"` Msg string `json:"errmsg"` }
网页授权用户的access token
type GetUserInfoRes ¶
type GetUserInfoRes 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"` Code int `json:"errcode"` Msg string `json:"errmsg"` }
用户信息
type UserEvent ¶
type UserEvent struct { ToUserName string `p:"ToUserName" xml:"ToUserName"` // 开发者微信号 FromUserName string `p:"FromUserName" xml:"FromUserName"` // 发送方账号(一个OpenID) CreateTime int `p:"CreateTime" xml:"CreateTime"` // 消息创建时间(整型) MsgType string `p:"MsgType" xml:"MsgType"` // 消息类型,event, Event string `p:"Event" xml:"Event"` // 事件类型,subscribe(关注), SCAN(已关注) EventKey string `p:"EventKey" xml:"EventKey"` // 事件KEY值,qrscene_为前缀,后面为二维码的参数值 Ticket string `p:"Ticket" xml:"Ticket"` // 二维码的ticket,可用来换取二维码图片 }
用户事件
type VerifyParams ¶
微信服务器验证
type WechatLangType ¶
type WechatLangType string
const ( WECHAT_LANG_CN WechatLangType = "cn" WECHAT_LANG_EN WechatLangType = "en" )
Click to show internal directories.
Click to hide internal directories.