applogin

package
v0.0.0-...-fce8f56 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: MIT Imports: 5 Imported by: 0

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

type AppLogin struct {
	AppId  string
	Secret string
}

func NewAppLogin

func NewAppLogin(appId, secret string) AppLogin

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"`
}

返回的数据结构

func (LoginReturn) GetUserInfo

func (ret LoginReturn) GetUserInfo() (UserInfo, error)

获取用户信息

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"`
}

用户信息

Jump to

Keyboard shortcuts

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