package wechat import ( mpoauth2 "github.com/chanxuehong/wechat/mp/oauth2" "github.com/chanxuehong/wechat/oauth2" "hudongzhuanjia/utils/define" ) var Endpoint = mpoauth2.NewEndpoint(define.WxAppId, define.Secret) func GetToken(code string) (*oauth2.Token, error) { client := oauth2.Client{ Endpoint: Endpoint, } return client.ExchangeToken(code) } func GetUserInfo(tk *oauth2.Token) (*mpoauth2.UserInfo, error) { return mpoauth2.GetUserInfo(tk.AccessToken, tk.OpenId, "", nil) } func MiniAuth(code string) (*mpoauth2.Session, error) { return mpoauth2.GetSession(Endpoint, code) }