Documentation
¶
Index ¶
Constants ¶
View Source
const ( // 获取access_token接口 AccessTokenApi = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code" // 刷新token RefreshTokenApi = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=%s&grant_type=refresh_token&refresh_token=%s" // 获取用户信息 UserInfoApi = "https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppLogin ¶
func NewAppLogin ¶
func (AppLogin) GetAccessToken ¶
func (app AppLogin) GetAccessToken(code string) (LoginReturn, error)
获取access_token
func (AppLogin) RefreshToken ¶
func (app AppLogin) RefreshToken(refreshToken string) (LoginReturn, error)
刷新token
type LoginReturn ¶
type LoginReturn struct {
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"`
}
返回的数据结构
type UserInfo ¶
type UserInfo struct {
OpenId string `json:"openid"`
Nickname string `json:"nickname"`
Sex int `json:"sex"` // 1为男性 2为女性
Province string `json:"province"`
City string `json:"city"`
Country string `json:"country"`
HeadImgUrl string `json:"headimgurl"`
UnionId string `json:"unionid"`
}
用户信息
Click to show internal directories.
Click to hide internal directories.