wechat

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//LoginURL 拼接微信登陆请求
	LoginURL string = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code"
	//RedirectURL 跳转微信登陆授权页
	RedirectURL string = "" /* 145-byte string literal not displayed */

	//UserInfoURL 微信用户信息
	UserInfoURL string = "https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s&lang=zh_CN"
	// UserInfoCgiURL 用户信息
	UserInfoCgiURL string = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=%s&openid=%s&lang=zh_CN"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MP

type MP struct {
	Appid       string      `json:"appid"`
	Appsecret   string      `json:"appsecret"`
	JsAPITicket jsAPITicket `json:"-"`
	AccessToken tokenType   `json:"-"`
}

MP 微信公众号

func (*MP) GetAccessToken

func (m *MP) GetAccessToken() (token string, err error)

GetAccessToken 获取token

func (*MP) GetJsAPITicket

func (m *MP) GetJsAPITicket() (ticket string, err error)

GetJsAPITicket 获取JsAPITicket

func (*MP) GetUserInfo

func (m *MP) GetUserInfo(code string) (result *UserInfo, err error)

GetUserInfo 发送code换取微信登陆信息

func (*MP) JsAPIConfig

func (m *MP) JsAPIConfig(url string) (conf map[string]string, err error)

JsAPIConfig 换取微信分享 jsapi授权

func (*MP) LoginRedirect

func (m *MP) LoginRedirect(redirectURI string) (url string)

LoginRedirect 获取登陆链接

type Mini

type Mini struct {
	Appid       string `json:"appid"`
	Appsecret   string `json:"appsecret"`
	AssessToken tokenType
}

Mini Mini

func (*Mini) GetAccessToken

func (m *Mini) GetAccessToken() (token string, err error)

GetAccessToken 获取token

func (*Mini) SendSubscribeMessage

func (m *Mini) SendSubscribeMessage(touser string, templateID string, page string, data map[string]interface{}) (err error)

SendSubscribeMessage 发送订阅消息

type UserInfo

type UserInfo struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int64  `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Openid       string `json:"openid"`
	Scope        string `json:"scope"`
	Nickname     string `json:"nickname"`
	Sex          int    `json:"sex"`
	Headimgurl   string `json:"headimgurl"`
	Province     string `json:"province"`
	City         string `json:"city"`
	Country      string `json:"country"`
	Unionid      string `json:"unionid"`
	Subscribe    int    `json:"subscribe"`
}

UserInfo 用户信息

Jump to

Keyboard shortcuts

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