Documentation ¶
Index ¶
- Constants
- type AccessTokenCallbackHandleFunc
- type AccessTokenContextHandle
- type AccessTokenHandle
- type CommonAccessToken
- type DefaultAccessToken
- type DefaultJsTicket
- type JsTicketHandle
- type MiniProgramStableAccessToken
- func (ak *MiniProgramStableAccessToken) GetAccessToken() (accessToken string, err error)
- func (ak *MiniProgramStableAccessToken) GetAccessTokenContext(ctx context.Context) (accessToken string, err error)
- func (ak *MiniProgramStableAccessToken) GetTokenFromServerContext(ctx context.Context, url string, isForceRefresh bool) (resAccessToken ResAccessToken, err error)
- func (ak *MiniProgramStableAccessToken) SetAccessTokenCallbackFunc(callbackFunc AccessTokenCallbackHandleFunc)
- type ResAccessToken
- type ResTicket
- type WorkAccessToken
Constants ¶
const ( // CacheKeyOfficialAccountPrefix 微信公众号cache key前缀 CacheKeyOfficialAccountPrefix = "gowechat_officialaccount_" // CacheKeyMiniProgramPrefix 小程序cache key前缀 CacheKeyMiniProgramPrefix = "gowechat_miniprogram_" )
const (
// CacheKeyMiniProgramStablePrefix 小程序cache key前缀
CacheKeyMiniProgramStablePrefix = "gowechat_miniprogram_stable_"
)
*
- 小程序AccessToken
const (
// CacheKeyWorkPrefix 企业微信cache key前缀
CacheKeyWorkPrefix = "gowechat_work_"
)
*
- 企业微信AccessToken
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessTokenCallbackHandleFunc ¶
AccessTokenCallbackHandleFunc 请求微信获取accessToken之后处理函数
type AccessTokenContextHandle ¶
type AccessTokenContextHandle interface { AccessTokenHandle GetAccessTokenContext(ctx context.Context) (accessToken string, err error) }
AccessTokenContextHandle AccessToken 接口
func NewDefaultAccessToken ¶
func NewDefaultAccessToken(appID, appSecret, cacheKeyPrefix string, cache cache.Cache) AccessTokenContextHandle
NewDefaultAccessToken new DefaultAccessToken
func NewWorkAccessToken ¶
func NewWorkAccessToken(corpID, corpSecret, agentId, cacheKeyPrefix string, cache cache.Cache) AccessTokenContextHandle
NewWorkAccessToken new WorkAccessToken
type AccessTokenHandle ¶
type AccessTokenHandle interface { GetAccessToken() (accessToken string, err error) SetAccessTokenCallbackFunc(funcHandle AccessTokenCallbackHandleFunc) }
AccessTokenHandle AccessToken 接口
type CommonAccessToken ¶
type DefaultAccessToken ¶
type DefaultAccessToken struct { CommonAccessToken // contains filtered or unexported fields }
DefaultAccessToken 默认AccessToken 获取
func (*DefaultAccessToken) GetAccessToken ¶
func (ak *DefaultAccessToken) GetAccessToken() (accessToken string, err error)
GetAccessToken 获取access_token,先从cache中获取,没有则从服务端获取
func (*DefaultAccessToken) GetAccessTokenContext ¶
func (ak *DefaultAccessToken) GetAccessTokenContext(ctx context.Context) (accessToken string, err error)
GetAccessTokenContext 获取access_token,先从cache中获取,没有则从服务端获取
func (*DefaultAccessToken) SetAccessTokenCallbackFunc ¶
func (ak *DefaultAccessToken) SetAccessTokenCallbackFunc(callbackFunc AccessTokenCallbackHandleFunc)
SetAccessTokenCallbackFunc 设置回调函数
type DefaultJsTicket ¶
type DefaultJsTicket struct {
// contains filtered or unexported fields
}
DefaultJsTicket 默认获取js ticket方法
type JsTicketHandle ¶
type JsTicketHandle interface { // GetTicket 获取ticket GetTicket(accessToken string) (ticket string, err error) }
JsTicketHandle js ticket获取
func NewDefaultJsTicket ¶
func NewDefaultJsTicket(appID string, cacheKeyPrefix string, cache cache.Cache) JsTicketHandle
NewDefaultJsTicket new
type MiniProgramStableAccessToken ¶ added in v0.0.15
type MiniProgramStableAccessToken struct { CommonAccessToken Appid string Secret string }
MiniProgramStableAccessToken 小程序AccessToken 获取
func NewMiniProgramStableAccessToken ¶ added in v0.0.15
func NewMiniProgramStableAccessToken(appid, secret, cacheKeyPrefix string, cache cache.Cache) *MiniProgramStableAccessToken
NewMiniProgramStableAccessToken new
func (*MiniProgramStableAccessToken) GetAccessToken ¶ added in v0.0.15
func (ak *MiniProgramStableAccessToken) GetAccessToken() (accessToken string, err error)
GetAccessToken 企业微信获取access_token,先从cache中获取,没有则从服务端获取
func (*MiniProgramStableAccessToken) GetAccessTokenContext ¶ added in v0.0.15
func (ak *MiniProgramStableAccessToken) GetAccessTokenContext(ctx context.Context) (accessToken string, err error)
GetAccessTokenContext 企业微信获取access_token,先从cache中获取,没有则从服务端获取
func (*MiniProgramStableAccessToken) GetTokenFromServerContext ¶ added in v0.0.15
func (ak *MiniProgramStableAccessToken) GetTokenFromServerContext(ctx context.Context, url string, isForceRefresh bool) (resAccessToken ResAccessToken, err error)
GetTokenFromServerContext 强制从微信服务器获取token
func (*MiniProgramStableAccessToken) SetAccessTokenCallbackFunc ¶ added in v0.0.15
func (ak *MiniProgramStableAccessToken) SetAccessTokenCallbackFunc(callbackFunc AccessTokenCallbackHandleFunc)
SetAccessTokenCallbackFunc 设置回调函数
type ResAccessToken ¶
type ResAccessToken struct { util.CommonError AccessToken string `json:"access_token"` ExpiresIn int64 `json:"expires_in"` }
ResAccessToken struct
func GetTokenFromServer ¶
func GetTokenFromServer(url string) (resAccessToken ResAccessToken, err error)
GetTokenFromServer 强制从微信服务器获取token
func GetTokenFromServerContext ¶
func GetTokenFromServerContext(ctx context.Context, url string) (resAccessToken ResAccessToken, err error)
GetTokenFromServerContext 强制从微信服务器获取token
type ResTicket ¶
type ResTicket struct { util.CommonError Ticket string `json:"ticket"` ExpiresIn int64 `json:"expires_in"` }
ResTicket 请求jsapi_tikcet返回结果
func GetTicketFromServer ¶
GetTicketFromServer 从服务器中获取ticket
type WorkAccessToken ¶
type WorkAccessToken struct { CommonAccessToken CorpID string CorpSecret string AgentId string }
WorkAccessToken 企业微信AccessToken 获取
func (*WorkAccessToken) GetAccessToken ¶
func (ak *WorkAccessToken) GetAccessToken() (accessToken string, err error)
GetAccessToken 企业微信获取access_token,先从cache中获取,没有则从服务端获取
func (*WorkAccessToken) GetAccessTokenContext ¶
func (ak *WorkAccessToken) GetAccessTokenContext(ctx context.Context) (accessToken string, err error)
GetAccessTokenContext 企业微信获取access_token,先从cache中获取,没有则从服务端获取
func (*WorkAccessToken) SetAccessTokenCallbackFunc ¶
func (ak *WorkAccessToken) SetAccessTokenCallbackFunc(callbackFunc AccessTokenCallbackHandleFunc)
SetAccessTokenCallbackFunc 设置回调函数