互动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
633 B

package wechat
import (
mpoauth2 "github.com/chanxuehong/wechat/mp/oauth2"
"github.com/chanxuehong/wechat/oauth2"
)
var (
Appid = "wx7b0bcf476552c5e9"
Secret = "f6aabdd40ea25272f4442603a7dc8028"
)
var Endpoint = mpoauth2.NewEndpoint(Appid, 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)
}