wechatoffice

package module
v0.0.0-...-05c9766 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	QdTypeDb  = "DB"
	QdTypeRdb = "redis"
)

Functions

This section is empty.

Types

type App

type App struct {
	AppId       string        // 小程序唯一凭证,即 AppID
	AppSecret   string        // 小程序唯一凭证密钥,即 AppSecret
	AccessToken string        // 接口调用凭证
	JsapiTicket string        // 签名凭证
	ZapLog      *zap.Logger   // 日志服务
	Db          *gorm.DB      // 关系数据库服务
	RDb         *redis.Client // 缓存数据库服务
	MDb         *mongo.Client // 非关系数据库服务
}

App 微信公众号服务

func (*App) AuthCode2Session

func (app *App) AuthCode2Session(jsCode string) *AuthCode2SessionResult

func (*App) AuthGetAccessTokenMonitor

func (app *App) AuthGetAccessTokenMonitor(qdType string) (string, error)

func (*App) AuthGetJsapiTicketMonitor

func (app *App) AuthGetJsapiTicketMonitor(qdType string) (string, error)

AuthGetJsapiTicketMonitor 监控api_ticket

func (*App) GetAccessTokenDb

func (app *App) GetAccessTokenDb() string

func (*App) GetAccessTokenRDb

func (app *App) GetAccessTokenRDb() string

func (*App) GetCallBackIp

func (app *App) GetCallBackIp() *GetCallBackIpResult

GetCallBackIp 获取微信callback IP地址 callback IP即微信调用开发者服务器所使用的出口IP。 https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_the_WeChat_server_IP_address.html#2.%20%E8%8E%B7%E5%8F%96%E5%BE%AE%E4%BF%A1callback%20IP%E5%9C%B0%E5%9D%80

func (*App) GetJsapiTicketDb

func (app *App) GetJsapiTicketDb() string

GetJsapiTicketDb 获取api_ticket

func (*App) GetJsapiTicketRDb

func (app *App) GetJsapiTicketRDb() string

GetJsapiTicketRDb 获取api_ticket

func (*App) GetTicket

func (app *App) GetTicket(accessToken, Type string) *GetTicketResult

GetTicket 获取api_ticket https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html

func (*App) MessageTemplateSend

func (app *App) MessageTemplateSend(notMustParams ...Params) *MessageTemplateSendResult

MessageTemplateSend 模板消息 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html

func (*App) NewParamsWith

func (app *App) NewParamsWith(params ...Params) Params

func (*App) Oauth2

func (app *App) Oauth2(redirectUri, state string) string

Oauth2 用户同意授权,获取code https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html#0

func (*App) Oauth2AccessToken

func (app *App) Oauth2AccessToken(code string) *Oauth2AccessTokenResult

Oauth2AccessToken 通过code换取网页授权access_token https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html#0

func (*App) Share

func (app *App) Share(url string) *ShareResult

func (*App) SnsUserinfo

func (app *App) SnsUserinfo(accessToken, openid string) *SnsUserinfoResult

SnsUserinfo 拉取用户信息(需scope为 snsapi_userinfo) https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html#0

type AuthCode2SessionResponse

type AuthCode2SessionResponse struct {
	OpenId     string `json:"openid"`      // 用户唯一标识
	SessionKey string `json:"session_key"` // 会话密钥
	Unionid    string `json:"unionid"`     // 用户在开放平台的唯一标识符,若当前小程序已绑定到微信开放平台帐号下会返回
	Errcode    string `json:"errcode"`     // 错误码
	Errmsg     string `json:"errmsg"`      // 错误信息
}

type AuthCode2SessionResult

type AuthCode2SessionResult struct {
	Result AuthCode2SessionResponse // 结果
	Body   []byte                   // 内容
	Err    error                    // 错误
}

func NewAuthCode2SessionResult

func NewAuthCode2SessionResult(result AuthCode2SessionResponse, body []byte, err error) *AuthCode2SessionResult

type AuthGetAccessTokenResponse

type AuthGetAccessTokenResponse struct {
	AccessToken string `json:"access_token"` // 获取到的凭证
	ExpiresIn   int    `json:"expires_in"`   // 凭证有效时间,单位:秒。目前是7200秒之内的值
	Errcode     int    `json:"errcode"`      // 错误码
	Errmsg      string `json:"errmsg"`       // 错误信息
}

type AuthGetAccessTokenResult

type AuthGetAccessTokenResult struct {
	Result AuthGetAccessTokenResponse // 结果
	Body   []byte                     // 内容
	Err    error                      // 错误
}

func NewAuthGetAccessTokenResult

func NewAuthGetAccessTokenResult(result AuthGetAccessTokenResponse, body []byte, err error) *AuthGetAccessTokenResult

type GetCallBackIpResponse

type GetCallBackIpResponse struct {
	IpList []string `json:"ip_list"`
}

type GetCallBackIpResult

type GetCallBackIpResult struct {
	Result GetCallBackIpResponse // 结果
	Body   []byte                // 内容
	Err    error                 // 错误
}

func NewGetCallBackIpResult

func NewGetCallBackIpResult(result GetCallBackIpResponse, body []byte, err error) *GetCallBackIpResult

type GetTicketRespons

type GetTicketRespons struct {
	Errcode   int    `json:"errcode"` // 错误码
	Errmsg    string `json:"errmsg"`  // 错误信息
	Ticket    string `json:"ticket"`
	ExpiresIn int    `json:"expires_in"`
}

type GetTicketResult

type GetTicketResult struct {
	Result GetTicketRespons // 结果
	Body   []byte           // 内容
	Err    error            // 错误
}

func NewGetTicketResult

func NewGetTicketResult(result GetTicketRespons, body []byte, err error) *GetTicketResult

type MessageTemplateSendResponse

type MessageTemplateSendResponse struct {
	Errcode int    `json:"errcode"`
	Errmsg  string `json:"errmsg"`
	Msgid   int    `json:"msgid"`
}

type MessageTemplateSendResult

type MessageTemplateSendResult struct {
	Result MessageTemplateSendResponse // 结果
	Body   []byte                      // 内容
	Err    error                       // 错误
}

func NewMessageTemplateSendResult

func NewMessageTemplateSendResult(result MessageTemplateSendResponse, body []byte, err error) *MessageTemplateSendResult

type Oauth2AccessTokenResponse

type Oauth2AccessTokenResponse struct {
	AccessToken  string `json:"access_token"`  // 网页授权接口调用凭证,注意:此access_token与基础支持的access_token不同
	ExpiresIn    int    `json:"expires_in"`    // access_token接口调用凭证超时时间,单位(秒)
	RefreshToken string `json:"refresh_token"` // 用户刷新access_token
	Openid       string `json:"openid"`        // 用户唯一标识
	Scope        string `json:"scope"`         // 用户授权的作用域,使用逗号(,)分隔
}

type Oauth2AccessTokenResult

type Oauth2AccessTokenResult struct {
	Result Oauth2AccessTokenResponse // 结果
	Body   []byte                    // 内容
	Err    error                     // 错误
}

func NewOauth2AccessTokenResult

func NewOauth2AccessTokenResult(result Oauth2AccessTokenResponse, body []byte, err error) *Oauth2AccessTokenResult

type Params

type Params map[string]interface{}

Params 请求参数

func NewParams

func NewParams() Params

func (Params) Set

func (p Params) Set(key string, value interface{})

func (Params) SetParams

func (p Params) SetParams(params Params)

type ShareResponse

type ShareResponse struct {
	AppId     string `json:"app_id"`
	NonceStr  string `json:"nonce_str"`
	Timestamp int64  `json:"timestamp"`
	Url       string `json:"url"`
	RawString string `json:"raw_string"`
	Signature string `json:"signature"`
}

type ShareResult

type ShareResult struct {
	Result ShareResponse // 结果
	Err    error         // 错误
}

func NewShareResult

func NewShareResult(result ShareResponse, err error) *ShareResult

type SnsUserinfoResponse

type SnsUserinfoResponse struct {
	Openid     string   `json:"openid"`            // 用户的唯一标识
	Nickname   string   `json:"nickname"`          // 用户昵称
	Sex        int      `json:"sex"`               // 用户的性别,值为1时是男性,值为2时是女性,值为0时是未知
	Province   string   `json:"province"`          // 用户个人资料填写的省份
	City       string   `json:"city"`              // 普通用户个人资料填写的城市
	Country    string   `json:"country"`           // 国家,如中国为CN
	Headimgurl string   `json:"headimgurl"`        // 用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空。若用户更换头像,原有头像URL将失效。
	Privilege  []string `json:"privilege"`         // 用户特权信息,json 数组,如微信沃卡用户为(chinaunicom)
	Unionid    string   `json:"unionid,omitempty"` // 只有在用户将公众号绑定到微信开放平台帐号后,才会出现该字段。
}

type SnsUserinfoResult

type SnsUserinfoResult struct {
	Result SnsUserinfoResponse // 结果
	Body   []byte              // 内容
	Err    error               // 错误
}

func NewSnsUserinfoResult

func NewSnsUserinfoResult(result SnsUserinfoResponse, body []byte, err error) *SnsUserinfoResult

type WechatAccessTokenDbModel

type WechatAccessTokenDbModel struct {
	ID          int64     `json:"id"`
	AppID       string    `json:"app_id"`
	AppSecret   string    `json:"app_secret"`
	AccessToken string    `json:"access_token"`
	ExpiresIn   int       `json:"expires_in"`
	ExpiresTime string    `json:"expires_time"`
	CreateTime  time.Time `gorm:"autoCreateTime" json:"-"`
}

func (*WechatAccessTokenDbModel) TableName

func (m *WechatAccessTokenDbModel) TableName() string

type WechatJsapiTicketDbModel

type WechatJsapiTicketDbModel struct {
	ID          int64     `json:"id"`
	AppID       string    `json:"app_id"`
	AppSecret   string    `json:"app_secret"`
	Ticket      string    `json:"ticket"`
	ExpiresIn   int       `json:"expires_in"`
	ExpiresTime string    `json:"expires_time"`
	CreateTime  time.Time `gorm:"autoCreateTime" json:"-"`
}

func (*WechatJsapiTicketDbModel) TableName

func (m *WechatJsapiTicketDbModel) TableName() string

Jump to

Keyboard shortcuts

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