Documentation ¶
Index ¶
- Constants
- Variables
- func AESDecryptMsg(ciphertext []byte, aesKey []byte) (random, rawXMLMsg, appID []byte, err error)
- func AESEncryptMsg(random, rawXMLMsg []byte, appID string, aesKey []byte) (ciphertext []byte, err error)
- func DecodeWithCommonError(apiName string, ce CommonError) (err error)
- func DecryptMsg(appID, encryptedMsg, aesKey string) (random, rawMsgXMLBytes []byte, err error)
- func EncryptMsg(random, rawXMLMsg []byte, appID, aesKey string) (encrtptMsg []byte, err error)
- func IsConflict(err interface{}) bool
- func IsConnErr(err error) bool
- func IsContextErr(err error) bool
- func IsForbidden(err interface{}) bool
- func IsNotFound(err interface{}) bool
- func IsStatusCode(err interface{}, code int) bool
- func IsTimeout(err interface{}) bool
- func MD5Sum(txt string) (sum string)
- func RandomStr(length int) []byte
- func Signature(params ...string) string
- type AccessToken
- type Article
- type BasicAccessToken
- type BasicMessage
- type Cache
- type Client
- func (c *Client) BasicAccessToken(accessToken IAccessToken) *BasicAccessToken
- func (c *Client) BasicMessage(accessToken IAccessToken, message IBasicMessage) *BasicMessage
- func (c *Client) IsRunning() bool
- func (c *Client) MiniProgramAccessToken() *MiniProgramAccessToken
- func (c *Client) MiniProgramActivityMessageCreate() *MiniProgramActivityMessageCreate
- func (c *Client) MiniProgramActivityMessageUpdate() *MiniProgramActivityMessageUpdate
- func (c *Client) MiniProgramAppCodeCreate() *MiniProgramAppCodeCreate
- func (c *Client) MiniProgramAppCodeGet() *MiniProgramAppCodeGet
- func (c *Client) MiniProgramAppCodeGetUnlimit() *MiniProgramAppCodeGetUnlimit
- func (c *Client) MiniProgramAuth() *MiniProgramAuth
- func (c *Client) MiniProgramPaid() *MiniProgramPaid
- func (c *Client) MiniProgramSecImg() *MiniProgramSecImg
- func (c *Client) MiniProgramSecMsg() *MiniProgramSecMsg
- func (c *Client) OfficeAccountAccessToken() *OfficeAccountAccessToken
- func (c *Client) PerformFormRequest(ctx context.Context, opt PerformRequestOptions) (*Response, error)
- func (c *Client) PerformRequest(ctx context.Context, opt PerformRequestOptions) (*Response, error)
- func (c *Client) Start()
- func (c *Client) Stop()
- func (c *Client) WorkAccessToken() *WorkAccessToken
- type ClientOptionFunc
- func SetCacheBackend(cache Cache) ClientOptionFunc
- func SetDecoder(decoder Decoder) ClientOptionFunc
- func SetErrorLog(logger Logger) ClientOptionFunc
- func SetGzip(enabled bool) ClientOptionFunc
- func SetHTTPClient(httpClient *http.Client) ClientOptionFunc
- func SetHTTPClientInsecureSkipVerify() ClientOptionFunc
- func SetInfoLog(logger Logger) ClientOptionFunc
- func SetScheme(scheme string) ClientOptionFunc
- func SetSendGetBodyAs(httpMethod string) ClientOptionFunc
- func SetTraceLog(logger Logger) ClientOptionFunc
- type CommonError
- type Decoder
- type DefaultDecoder
- type DefaultLogger
- type Error
- type ErrorDetails
- type File
- type IAccessToken
- type IBasicMessage
- type Image
- type Logger
- type MPAMUpdateBodyParameterList
- type MPAMUpdateBodyTemplateInfo
- type MPSubscribeMessage
- type MPSubscribeMessageBody
- type Markdown
- type MemCache
- type MemCacheOptFunc
- type MiniProgramAccessToken
- func (mpat *MiniProgramAccessToken) Credentials(ctx context.Context) (*AccessToken, error)
- func (mpat *MiniProgramAccessToken) Do(ctx context.Context) (*MiniProgramAccessTokenResponse, error)
- func (mpat *MiniProgramAccessToken) SetAppID(appid string) *MiniProgramAccessToken
- func (mpat *MiniProgramAccessToken) SetGrantType() *MiniProgramAccessToken
- func (mpat *MiniProgramAccessToken) SetSecret(secret string) *MiniProgramAccessToken
- func (mpat *MiniProgramAccessToken) ToString() string
- func (mpat *MiniProgramAccessToken) Validate() error
- type MiniProgramAccessTokenResponse
- type MiniProgramActivityMessageCreate
- type MiniProgramActivityMessageCreateResponse
- type MiniProgramActivityMessageUpdate
- func (mpamu *MiniProgramActivityMessageUpdate) Do(ctx context.Context) (*MiniProgramActivityMessageUpdateResponse, error)
- func (mpamu *MiniProgramActivityMessageUpdate) SetAccessToken(accessToken string) *MiniProgramActivityMessageUpdate
- func (mpamu *MiniProgramActivityMessageUpdate) SetBody(body *MiniProgramActivityMessageUpdateBody) *MiniProgramActivityMessageUpdate
- func (mpamu *MiniProgramActivityMessageUpdate) Validate() error
- type MiniProgramActivityMessageUpdateBody
- type MiniProgramActivityMessageUpdateResponse
- type MiniProgramAppCodeCreate
- func (mpb *MiniProgramAppCodeCreate) Do(ctx context.Context) (*MiniProgramAppCodeCreateResponse, error)
- func (mpb *MiniProgramAppCodeCreate) SetAccessToken(accessToken string) *MiniProgramAppCodeCreate
- func (mpb *MiniProgramAppCodeCreate) SetMchID(mchID string) *MiniProgramAppCodeCreate
- func (mpb *MiniProgramAppCodeCreate) SetOpenID(openid string) *MiniProgramAppCodeCreate
- func (mpb *MiniProgramAppCodeCreate) SetOutTradeNo(outTradeNo string) *MiniProgramAppCodeCreate
- func (mpb *MiniProgramAppCodeCreate) SetTransactionID(transactionID string) *MiniProgramAppCodeCreate
- func (mpb *MiniProgramAppCodeCreate) SetUsingTransID() *MiniProgramAppCodeCreate
- func (mpb *MiniProgramAppCodeCreate) Validate() error
- type MiniProgramAppCodeCreateResponse
- type MiniProgramAppCodeGet
- func (mpb *MiniProgramAppCodeGet) Do(ctx context.Context) (*MiniProgramAppCodeGetResponse, error)
- func (mpb *MiniProgramAppCodeGet) SetAccessToken(accessToken string) *MiniProgramAppCodeGet
- func (mpb *MiniProgramAppCodeGet) SetMchID(mchID string) *MiniProgramAppCodeGet
- func (mpb *MiniProgramAppCodeGet) SetOpenID(openid string) *MiniProgramAppCodeGet
- func (mpb *MiniProgramAppCodeGet) SetOutTradeNo(outTradeNo string) *MiniProgramAppCodeGet
- func (mpb *MiniProgramAppCodeGet) SetTransactionID(transactionID string) *MiniProgramAppCodeGet
- func (mpb *MiniProgramAppCodeGet) SetUsingTransID() *MiniProgramAppCodeGet
- func (mpb *MiniProgramAppCodeGet) Validate() error
- type MiniProgramAppCodeGetResponse
- type MiniProgramAppCodeGetUnlimit
- func (mpb *MiniProgramAppCodeGetUnlimit) Do(ctx context.Context) (*MiniProgramAppCodeGetUnlimitResponse, error)
- func (mpb *MiniProgramAppCodeGetUnlimit) SetAccessToken(accessToken string) *MiniProgramAppCodeGetUnlimit
- func (mpb *MiniProgramAppCodeGetUnlimit) SetMchID(mchID string) *MiniProgramAppCodeGetUnlimit
- func (mpb *MiniProgramAppCodeGetUnlimit) SetOpenID(openid string) *MiniProgramAppCodeGetUnlimit
- func (mpb *MiniProgramAppCodeGetUnlimit) SetOutTradeNo(outTradeNo string) *MiniProgramAppCodeGetUnlimit
- func (mpb *MiniProgramAppCodeGetUnlimit) SetTransactionID(transactionID string) *MiniProgramAppCodeGetUnlimit
- func (mpb *MiniProgramAppCodeGetUnlimit) SetUsingTransID() *MiniProgramAppCodeGetUnlimit
- func (mpb *MiniProgramAppCodeGetUnlimit) Validate() error
- type MiniProgramAppCodeGetUnlimitResponse
- type MiniProgramAuth
- func (mpa *MiniProgramAuth) Do(ctx context.Context) (*MiniProgramAuthResponse, error)
- func (mpa *MiniProgramAuth) SetAppID(appid string) *MiniProgramAuth
- func (mpa *MiniProgramAuth) SetGrantType() *MiniProgramAuth
- func (mpa *MiniProgramAuth) SetJscode(jscode string) *MiniProgramAuth
- func (mpa *MiniProgramAuth) SetSecret(secret string) *MiniProgramAuth
- func (mpa *MiniProgramAuth) Validate() error
- type MiniProgramAuthResponse
- type MiniProgramPaid
- func (mpb *MiniProgramPaid) Do(ctx context.Context) (*MiniProgramPaidResponse, error)
- func (mpb *MiniProgramPaid) SetAccessToken(accessToken string) *MiniProgramPaid
- func (mpb *MiniProgramPaid) SetMchID(mchID string) *MiniProgramPaid
- func (mpb *MiniProgramPaid) SetOpenID(openid string) *MiniProgramPaid
- func (mpb *MiniProgramPaid) SetOutTradeNo(outTradeNo string) *MiniProgramPaid
- func (mpb *MiniProgramPaid) SetTransactionID(transactionID string) *MiniProgramPaid
- func (mpb *MiniProgramPaid) SetUsingTransID() *MiniProgramPaid
- func (mpb *MiniProgramPaid) Validate() error
- type MiniProgramPaidResponse
- type MiniProgramSecImg
- type MiniProgramSecImgResponse
- type MiniProgramSecMsg
- type MiniProgramSecMsgResponse
- type MiniProgramUniformMessage
- type MiniProgramUniformMessageBody
- type MiniprogramContentItem
- type MiniprogramNotice
- type MpArticle
- type MpTemplateMsg
- type Mpnews
- type News
- type NumberDecoder
- type OACustomImage
- type OACustomMessage
- type OACustomMessageBody
- type OACustomMiniprogrampage
- type OACustomMpnews
- type OACustomMsgmenu
- type OACustomMusic
- type OACustomNews
- type OACustomText
- type OACustomVideo
- type OACustomVoice
- type OACustomWXCard
- type OACustomservice
- type OfficeAccountAccessToken
- func (mpat *OfficeAccountAccessToken) Credentials(ctx context.Context) (*AccessToken, error)
- func (mpat *OfficeAccountAccessToken) Do(ctx context.Context) (*OfficeAccountAccessTokenResponse, error)
- func (mpat *OfficeAccountAccessToken) SetAppID(appid string) *OfficeAccountAccessToken
- func (mpat *OfficeAccountAccessToken) SetGrantType() *OfficeAccountAccessToken
- func (mpat *OfficeAccountAccessToken) SetSecret(secret string) *OfficeAccountAccessToken
- func (mpat *OfficeAccountAccessToken) ToString() string
- func (mpat *OfficeAccountAccessToken) Validate() error
- type OfficeAccountAccessTokenResponse
- type PerformRequestOptions
- type Request
- type Response
- type Taskcard
- type TaskcardBtn
- type Text
- type Textcard
- type Video
- type Voice
- type WXBizDataCrypt
- type WeappTemplateMsg
- type WorkAccessToken
- func (wat *WorkAccessToken) Credentials(ctx context.Context) (*AccessToken, error)
- func (wat *WorkAccessToken) Do(ctx context.Context) (*WorkAccessTokenResponse, error)
- func (wat *WorkAccessToken) SetAgentID(agentid string) *WorkAccessToken
- func (wat *WorkAccessToken) SetAppID(corpid string) *WorkAccessToken
- func (wat *WorkAccessToken) SetSecret(corpsecret string) *WorkAccessToken
- func (wat *WorkAccessToken) ToString() string
- func (wat *WorkAccessToken) Validate() error
- type WorkAccessTokenResponse
- type WorkAppMessage
- type WorkAppMessageBody
- type XMLDecoder
Constants ¶
const ( // OfficeAccountBaseHost base uri OfficeAccountBaseHost = "api.weixin.qq.com" // MiniProgramBaseHost base uri MiniProgramBaseHost = "api.weixin.qq.com" // WorkBaseHost work base uri WorkBaseHost = "qyapi.weixin.qq.com" )
const ( DefaultInterval time.Duration = 1 * time.Minute // min unit set to ms DefaultExpiration time.Duration = 0 NoExpiration time.Duration = -1 )
const of cache
const ( // Version is the current version of wechat. Version = "0.0.3" // DefaultScheme is the default protocol scheme to use. DefaultScheme = "https" // DefaultSendGetBodyAs is the HTTP method to use when wechat is sending // a GET request with a body. DefaultSendGetBodyAs = "GET" // DefaultGzipEnabled specifies if gzip compression is enabled by default. DefaultGzipEnabled = false // DefaultCacheExpiration of access token DefaultCacheExpiration = 7200 * time.Second // DefaultCacheInterval cleanup cache DefaultCacheInterval = 240 * time.Minute )
const ( MiniProgramAppCodeGetEndpoint = "wxa/getwxacode" MiniProgramAppCodeGetUnlimitEndpoint = "wxa/getwxacodeunlimit" MiniProgramAppCodeCreateEndpoint = "cgi-bin/wxaapp/createwxaqrcode" )
Endpoint
const ( MiniProgramActivityMessageCreateEndpoint = "cgi-bin/message/wxopen/activityid/create" MiniProgramActivityMessageUpdateEndpoint = "cgi-bin/message/wxopen/updatablemsg/send" )
Endpoint
const (
// MPSubscribeMessageEndpoint https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.send.html
MPSubscribeMessageEndpoint = "cgi-bin/message/subscribe/send"
)
const (
// MiniProgramAccessTokenEndpoint Endpoint
MiniProgramAccessTokenEndpoint = "cgi-bin/token"
)
const (
// MiniProgramAuthEndpoint Endpoint
MiniProgramAuthEndpoint = "sns/jscode2session"
)
const (
// MiniProgramPaidEndpoint Endpoint
MiniProgramPaidEndpoint = "wxa/getpaidunionid"
)
const (
MiniProgramSecImgEndpoint = "wxa/img_sec_check"
)
Endpoint
const (
MiniProgramSecMsgEndpoint = "wxa/msg_sec_check"
)
Endpoint
const ( // MiniProgramUniformMessageEndpoint .. // 这个接口的初衷就是想大家在开发小程序的时候,如果要发送公众号消息直接使用这个接口就可以了,无需再去调用公众号的模板消息接口 MiniProgramUniformMessageEndpoint = "cgi-bin/message/wxopen/template/uniform_send" )
const (
// OACustomMessageEndpoint https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Service_Center_messages.html
OACustomMessageEndpoint = "cgi-bin/message/custom/send"
)
const (
// OfficeAccountAccessTokenEndpoint Endpoint
OfficeAccountAccessTokenEndpoint = "cgi-bin/token"
)
const (
// WorkAccessTokenEndpoint Endpoint
WorkAccessTokenEndpoint = "cgi-bin/gettoken"
)
const (
// WorkAppMessageEndpoint Endpoint
WorkAppMessageEndpoint = "cgi-bin/message/send"
)
Variables ¶
var ( // ErrNoClient is raised when no Wechat node is available. ErrNoClient = errors.New("no Wechat node available") // ErrTimeout is raised when a request timed out, e.g. when WaitForStatus // didn't return in time. ErrTimeout = errors.New("timeout") // ErrNoBaseURI is raised when no base uri is available ErrNoBaseURI = errors.New("no base uri available") // ErrNoEndpoint is raised when no endpoint is available ErrNoEndpoint = errors.New("no endpoint available") )
var ( ErrAppIDNotMatch = errors.New("app id not match") ErrInvalidBlockSize = errors.New("invalid block size") ErrInvalidPKCS7Data = errors.New("invalid PKCS7 data") ErrInvalidPKCS7Padding = errors.New("invalid padding on input") )
err
var (
ErrCacheKeyNotExist = errors.New("key not exist")
)
var of cache
var ( // ErrResponseSize is raised if a response body exceeds the given max body size. ErrResponseSize = errors.New("wechat: response size too large") )
var (
ErrUserRefuseToAccept = errors.New("user refuse to accept the msg")
)
err
Functions ¶
func AESDecryptMsg ¶
AESDecryptMsg ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId]
func AESEncryptMsg ¶
func AESEncryptMsg(random, rawXMLMsg []byte, appID string, aesKey []byte) (ciphertext []byte, err error)
AESEncryptMsg ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId]
func DecodeWithCommonError ¶
func DecodeWithCommonError(apiName string, ce CommonError) (err error)
DecodeWithCommonError DecodeWithCommonError
func DecryptMsg ¶
DecryptMsg DecryptMsg
func EncryptMsg ¶
EncryptMsg EncryptMsg
func IsConflict ¶
func IsConflict(err interface{}) bool
IsConflict returns true if the given error indicates that the wechat operation resulted in a version conflict. This can occur in operations like `update` or `index` with `op_type=create`. The err parameter can be of type *wechat.Error, wechat.Error, *http.Response or int (indicating the HTTP status code).
func IsConnErr ¶
IsConnErr returns true if the error indicates that wechat could not find an wechat host to connect to.
func IsContextErr ¶
IsContextErr returns true if the error is from a context that was canceled or deadline exceeded
func IsForbidden ¶
func IsForbidden(err interface{}) bool
IsForbidden returns true if the given error indicates that wechat returned HTTP status 403. This happens e.g. due to a missing license. The err parameter can be of type *wechat.Error, wechat.Error, *http.Response or int (indicating the HTTP status code).
func IsNotFound ¶
func IsNotFound(err interface{}) bool
IsNotFound returns true if the given error indicates that wechat returned HTTP status 404. The err parameter can be of type *wechat.Error, wechat.Error, *http.Response or int (indicating the HTTP status code).
func IsStatusCode ¶
IsStatusCode returns true if the given error indicates that the wechat operation returned the specified HTTP status code. The err parameter can be of type *http.Response, *Error, Error, or int (indicating the HTTP status code).
Types ¶
type AccessToken ¶
type AccessToken struct { AccessToken string `json:"access_token"` ExpiresIn int64 `json:"expires_in"` }
AccessToken AccessToken
type Article ¶
type Article struct { Title string `json:"title"` Description string `json:"description"` URL string `json:"url"` Picurl string `json:"picurl"` }
Article Article
type BasicAccessToken ¶
type BasicAccessToken struct {
// contains filtered or unexported fields
}
BasicAccessToken BasicAccessToken
func NewBasicAccessToken ¶
func NewBasicAccessToken(c *Client, accessToken IAccessToken) *BasicAccessToken
NewBasicAccessToken NewBasicAccessToken
func (*BasicAccessToken) GetToken ¶
func (bat *BasicAccessToken) GetToken(ctx context.Context, refresh bool) (accessToken string)
GetToken GetToken
func (*BasicAccessToken) RefreshToken ¶
func (bat *BasicAccessToken) RefreshToken(ctx context.Context) string
RefreshToken RefreshToken
func (*BasicAccessToken) SetToken ¶
func (bat *BasicAccessToken) SetToken(ctx context.Context, at *AccessToken) error
SetToken SetToken
type BasicMessage ¶
type BasicMessage struct {
// contains filtered or unexported fields
}
BasicMessage 消息结构体,用于拼装消息、发送消息
func NewBasicMessage ¶
func NewBasicMessage(c *Client, accessToken IAccessToken, message IBasicMessage) *BasicMessage
NewBasicMessage NewBasicMessage
type Cache ¶
type Cache interface { Get(ctx context.Context, key string) (interface{}, error) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error Delete(ctx context.Context, key string) error }
Cache interface for store access token.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a common wechat client. Create one by calling NewClient.
func NewClient ¶
func NewClient(options ...ClientOptionFunc) (*Client, error)
NewClient creates a new short-lived Client that can be used in use cases where you need e.g. one client per request.
func (*Client) BasicAccessToken ¶
func (c *Client) BasicAccessToken(accessToken IAccessToken) *BasicAccessToken
BasicAccessToken BasicAccessToken
func (*Client) BasicMessage ¶
func (c *Client) BasicMessage(accessToken IAccessToken, message IBasicMessage) *BasicMessage
BasicMessage BasicMessage
func (*Client) IsRunning ¶
IsRunning returns true if the background processes of the client are running, false otherwise.
func (*Client) MiniProgramAccessToken ¶
func (c *Client) MiniProgramAccessToken() *MiniProgramAccessToken
MiniProgramAccessToken Miniprogram Auth
func (*Client) MiniProgramActivityMessageCreate ¶
func (c *Client) MiniProgramActivityMessageCreate() *MiniProgramActivityMessageCreate
MiniProgramActivityMessageCreate MiniProgramActivityMessageCreate
func (*Client) MiniProgramActivityMessageUpdate ¶
func (c *Client) MiniProgramActivityMessageUpdate() *MiniProgramActivityMessageUpdate
MiniProgramActivityMessageUpdate MiniProgramActivityMessageUpdate
func (*Client) MiniProgramAppCodeCreate ¶
func (c *Client) MiniProgramAppCodeCreate() *MiniProgramAppCodeCreate
MiniProgramAppCodeCreate MiniProgramAppCodeCreate
func (*Client) MiniProgramAppCodeGet ¶
func (c *Client) MiniProgramAppCodeGet() *MiniProgramAppCodeGet
MiniProgramAppCodeGet MiniProgramAppCodeGet
func (*Client) MiniProgramAppCodeGetUnlimit ¶
func (c *Client) MiniProgramAppCodeGetUnlimit() *MiniProgramAppCodeGetUnlimit
MiniProgramAppCodeGetUnlimit MiniProgramAppCodeGetUnlimit
func (*Client) MiniProgramAuth ¶
func (c *Client) MiniProgramAuth() *MiniProgramAuth
MiniProgramAuth Miniprogram Auth
func (*Client) MiniProgramPaid ¶
func (c *Client) MiniProgramPaid() *MiniProgramPaid
MiniProgramPaid Miniprogram Auth
func (*Client) MiniProgramSecImg ¶
func (c *Client) MiniProgramSecImg() *MiniProgramSecImg
MiniProgramSecImg MiniProgramSecImg
func (*Client) MiniProgramSecMsg ¶
func (c *Client) MiniProgramSecMsg() *MiniProgramSecMsg
MiniProgramSecMsg MiniProgramSecMsg
func (*Client) OfficeAccountAccessToken ¶ added in v0.0.6
func (c *Client) OfficeAccountAccessToken() *OfficeAccountAccessToken
MiniProgramAccessToken Miniprogram Auth
func (*Client) PerformFormRequest ¶
func (c *Client) PerformFormRequest(ctx context.Context, opt PerformRequestOptions) (*Response, error)
PerformFormRequest does a HTTP request to wechat.
func (*Client) PerformRequest ¶
PerformRequest does a HTTP request to wechat.
func (*Client) Start ¶
func (c *Client) Start()
Start starts the background processes like periodic health checks. You don't need to run Start when creating a client with NewClient; the background processes are run by default.
If the background processes are already running, this is a no-op.
func (*Client) Stop ¶
func (c *Client) Stop()
Stop stops the background processes that the client is running,
If the background processes are not running, this is a no-op.
func (*Client) WorkAccessToken ¶
func (c *Client) WorkAccessToken() *WorkAccessToken
WorkAccessToken WorkAccessToken
type ClientOptionFunc ¶
ClientOptionFunc is a function that configures a Client. It is used in NewClient.
func SetCacheBackend ¶
func SetCacheBackend(cache Cache) ClientOptionFunc
SetCacheBackend SetCacheBackend which implentment Cache interface
func SetDecoder ¶
func SetDecoder(decoder Decoder) ClientOptionFunc
SetDecoder sets the Decoder to use when decoding data from Wechat. DefaultDecoder is used by default.
func SetErrorLog ¶
func SetErrorLog(logger Logger) ClientOptionFunc
SetErrorLog sets the logger for critical messages like nodes joining or leaving the cluster or failing requests. It is nil by default.
func SetGzip ¶
func SetGzip(enabled bool) ClientOptionFunc
SetGzip enables or disables gzip compression (disabled by default).
func SetHTTPClient ¶
func SetHTTPClient(httpClient *http.Client) ClientOptionFunc
SetHTTPClient can be used to specify the http.Client to use when making HTTP requests to wechat.
func SetHTTPClientInsecureSkipVerify ¶
func SetHTTPClientInsecureSkipVerify() ClientOptionFunc
SetHTTPClientInsecureSkipVerify SetHTTPClientInsecureSkipVerify
func SetInfoLog ¶
func SetInfoLog(logger Logger) ClientOptionFunc
SetInfoLog sets the logger for informational messages, e.g. requests and their response times. It is nil by default.
func SetScheme ¶
func SetScheme(scheme string) ClientOptionFunc
SetScheme sets the HTTP scheme to look for when sniffing (http or https). This is http by default.
func SetSendGetBodyAs ¶
func SetSendGetBodyAs(httpMethod string) ClientOptionFunc
SetSendGetBodyAs specifies the HTTP method to use when sending a GET request with a body. It is GET by default.
func SetTraceLog ¶
func SetTraceLog(logger Logger) ClientOptionFunc
SetTraceLog specifies the log.Logger to use for output of HTTP requests and responses which is helpful during debugging. It is nil by default.
type CommonError ¶
CommonError CommonError
type Decoder ¶
Decoder is used to decode responses from wechat. Users of wechat can implement their own marshaler for advanced purposes and set them per Client (see SetDecoder). If none is specified, DefaultDecoder is used.
type DefaultDecoder ¶
type DefaultDecoder struct{}
DefaultDecoder uses json.Unmarshal from the Go standard library to decode JSON data.
func (*DefaultDecoder) Decode ¶
func (u *DefaultDecoder) Decode(data []byte, v interface{}) error
Decode decodes with json.Unmarshal from the Go standard library.
type DefaultLogger ¶
type DefaultLogger struct{}
DefaultLogger DefaultLogger
func (*DefaultLogger) Printf ¶
func (l *DefaultLogger) Printf(format string, v ...interface{})
Printf Printf
type Error ¶
type Error struct { Status int `json:"status"` Details *ErrorDetails `json:"error,omitempty"` }
Error encapsulates error details as returned from wechat.
type ErrorDetails ¶
type ErrorDetails struct { Type string `json:"type"` Reason string `json:"reason"` ResourceType string `json:"resource.type,omitempty"` ResourceID string `json:"resource.id,omitempty"` Index string `json:"index,omitempty"` Phase string `json:"phase,omitempty"` Grouped bool `json:"grouped,omitempty"` CausedBy map[string]interface{} `json:"caused_by,omitempty"` RootCause []*ErrorDetails `json:"root_cause,omitempty"` FailedShards []map[string]interface{} `json:"failed_shards,omitempty"` }
ErrorDetails encapsulate error details from wechat. It is used in e.g. wechat.Error and wechat.BulkResponseItem.
type IAccessToken ¶
type IAccessToken interface { Credentials(ctx context.Context) (*AccessToken, error) ToString() string }
IAccessToken AccessToken接口,不同类型应用只需要实现该接口即可管理 accesstoken
type IBasicMessage ¶
type IBasicMessage interface { Body() interface{} Validate() error BaseURI() string Endpoint() string Params() url.Values }
IBasicMessage 发送消息的接口,不同消息只需要实现该接口即可
type Logger ¶
type Logger interface {
Printf(format string, v ...interface{})
}
Logger specifies the interface for all log operations.
type MPAMUpdateBodyParameterList ¶
MPAMUpdateBodyParameterList MPAMUpdateBodyParameterList
type MPAMUpdateBodyTemplateInfo ¶
type MPAMUpdateBodyTemplateInfo struct {
ParameterList []*MPAMUpdateBodyParameterList `json:"parameter_list"`
}
MPAMUpdateBodyTemplateInfo MPAMUpdateBodyTemplateInfo
type MPSubscribeMessage ¶
type MPSubscribeMessage struct { MsgBody *MPSubscribeMessageBody MsgParams url.Values }
MPSubscribeMessage 实现 IBasicMessage 接口
func NewMPSubscribeMessage ¶
func NewMPSubscribeMessage(sm *MPSubscribeMessage) *MPSubscribeMessage
NewMPSubscribeMessage 订阅消息
func (*MPSubscribeMessage) BaseURI ¶
func (mpum *MPSubscribeMessage) BaseURI() string
BaseURI BaseURI
func (*MPSubscribeMessage) Endpoint ¶
func (mpum *MPSubscribeMessage) Endpoint() string
Endpoint Endpoint
func (*MPSubscribeMessage) Params ¶
func (mpum *MPSubscribeMessage) Params() url.Values
Params Params
func (*MPSubscribeMessage) Validate ¶
func (mpum *MPSubscribeMessage) Validate() error
Validate Validate
type MPSubscribeMessageBody ¶
type MPSubscribeMessageBody struct { ToUser string `json:"touser"` TemplateID string `json:"template_id"` Page string `json:"page"` Data map[string]struct { Value string `json:"value"` } `json:"data"` MiniprogramState string `json:"miniprogram_state"` Lang string `json:"lang"` }
MPSubscribeMessageBody 消息体
type MemCache ¶
type MemCache struct {
// contains filtered or unexported fields
}
MemCache 默认走内存 cache,accesstoken 量不大,内存可以
func NewMemCache ¶
func NewMemCache(options ...MemCacheOptFunc) (*MemCache, error)
NewMemCache NewMemCache
type MemCacheOptFunc ¶
MemCacheOptFunc MemCacheOptFunc
func SetDefaultExpiration ¶
func SetDefaultExpiration(exp time.Duration) MemCacheOptFunc
SetDefaultExpiration SetDefaultExpiration
func SetDefaultInterval ¶
func SetDefaultInterval(inter time.Duration) MemCacheOptFunc
SetDefaultInterval SetDefaultInterval
type MiniProgramAccessToken ¶
type MiniProgramAccessToken struct {
// contains filtered or unexported fields
}
MiniProgramAccessToken MiniProgramAccessToken
func NewMiniProgramAccessToken ¶
func NewMiniProgramAccessToken(client *Client) *MiniProgramAccessToken
NewMiniProgramAccessToken return instance of MiniProgramAccessToken
func (*MiniProgramAccessToken) Credentials ¶
func (mpat *MiniProgramAccessToken) Credentials(ctx context.Context) (*AccessToken, error)
Credentials Credentials
func (*MiniProgramAccessToken) Do ¶
func (mpat *MiniProgramAccessToken) Do(ctx context.Context) (*MiniProgramAccessTokenResponse, error)
Do Do
func (*MiniProgramAccessToken) SetAppID ¶
func (mpat *MiniProgramAccessToken) SetAppID(appid string) *MiniProgramAccessToken
SetAppID SetAppID
func (*MiniProgramAccessToken) SetGrantType ¶
func (mpat *MiniProgramAccessToken) SetGrantType() *MiniProgramAccessToken
SetGrantType SetGrantType
func (*MiniProgramAccessToken) SetSecret ¶
func (mpat *MiniProgramAccessToken) SetSecret(secret string) *MiniProgramAccessToken
SetSecret SetSecret
func (*MiniProgramAccessToken) ToString ¶
func (mpat *MiniProgramAccessToken) ToString() string
ToString ToString
func (*MiniProgramAccessToken) Validate ¶
func (mpat *MiniProgramAccessToken) Validate() error
Validate checks if the operation is valid.
type MiniProgramAccessTokenResponse ¶
type MiniProgramAccessTokenResponse struct { CommonError AccessToken string `json:"access_token"` ExpiresIn int64 `json:"expires_in"` }
MiniProgramAccessTokenResponse MiniProgramAccessTokenResponse
type MiniProgramActivityMessageCreate ¶
type MiniProgramActivityMessageCreate struct {
// contains filtered or unexported fields
}
MiniProgramActivityMessageCreate MiniProgramActivityMessageCreateCreate
func NewMiniProgramActivityMessageCreate ¶
func NewMiniProgramActivityMessageCreate(client *Client) *MiniProgramActivityMessageCreate
NewMiniProgramActivityMessageCreate return instance of mini program auth
func (*MiniProgramActivityMessageCreate) Do ¶
func (mpam *MiniProgramActivityMessageCreate) Do(ctx context.Context) (*MiniProgramActivityMessageCreateResponse, error)
Do Do
func (*MiniProgramActivityMessageCreate) SetAccessToken ¶
func (mpam *MiniProgramActivityMessageCreate) SetAccessToken(accessToken string) *MiniProgramActivityMessageCreate
SetAccessToken SetAccessToken
func (*MiniProgramActivityMessageCreate) Validate ¶
func (mpam *MiniProgramActivityMessageCreate) Validate() error
Validate checks if the operation is valid.
type MiniProgramActivityMessageCreateResponse ¶
type MiniProgramActivityMessageCreateResponse struct { CommonError ActivityID string `json:"activity_id"` ExpirationTime string `json:"expiration_time"` }
MiniProgramActivityMessageCreateResponse MiniProgramActivityMessageCreateResponse
type MiniProgramActivityMessageUpdate ¶
type MiniProgramActivityMessageUpdate struct {
// contains filtered or unexported fields
}
MiniProgramActivityMessageUpdate MiniProgramActivityMessageUpdateCreate
func NewMiniProgramActivityMessageUpdate ¶
func NewMiniProgramActivityMessageUpdate(client *Client) *MiniProgramActivityMessageUpdate
NewMiniProgramActivityMessageUpdate return instance of mini program auth
func (*MiniProgramActivityMessageUpdate) Do ¶
func (mpamu *MiniProgramActivityMessageUpdate) Do(ctx context.Context) (*MiniProgramActivityMessageUpdateResponse, error)
Do Do
func (*MiniProgramActivityMessageUpdate) SetAccessToken ¶
func (mpamu *MiniProgramActivityMessageUpdate) SetAccessToken(accessToken string) *MiniProgramActivityMessageUpdate
SetAccessToken SetAccessToken
func (*MiniProgramActivityMessageUpdate) SetBody ¶
func (mpamu *MiniProgramActivityMessageUpdate) SetBody(body *MiniProgramActivityMessageUpdateBody) *MiniProgramActivityMessageUpdate
SetBody SetBody
func (*MiniProgramActivityMessageUpdate) Validate ¶
func (mpamu *MiniProgramActivityMessageUpdate) Validate() error
Validate checks if the operation is valid.
type MiniProgramActivityMessageUpdateBody ¶
type MiniProgramActivityMessageUpdateBody struct { ActivityID string `json:"activity_id"` TargetState int64 `json:"target_state"` TemplateInfo *MPAMUpdateBodyTemplateInfo `json:"template_info"` }
MiniProgramActivityMessageUpdateBody MiniProgramActivityMessageUpdateBody
func (*MiniProgramActivityMessageUpdateBody) Validate ¶
func (mpamub *MiniProgramActivityMessageUpdateBody) Validate() error
Validate Validate
type MiniProgramActivityMessageUpdateResponse ¶
type MiniProgramActivityMessageUpdateResponse struct {
CommonError
}
MiniProgramActivityMessageUpdateResponse MiniProgramActivityMessageUpdateResponse
type MiniProgramAppCodeCreate ¶
type MiniProgramAppCodeCreate struct {
// contains filtered or unexported fields
}
MiniProgramAppCodeCreate MiniProgramAppCodeCreate
func NewMiniProgramAppCodeCreate ¶
func NewMiniProgramAppCodeCreate(client *Client) *MiniProgramAppCodeCreate
NewMiniProgramAppCodeCreate return instance of NewMiniProgramAppCodeCreate
func (*MiniProgramAppCodeCreate) Do ¶
func (mpb *MiniProgramAppCodeCreate) Do(ctx context.Context) (*MiniProgramAppCodeCreateResponse, error)
Do Do
func (*MiniProgramAppCodeCreate) SetAccessToken ¶
func (mpb *MiniProgramAppCodeCreate) SetAccessToken(accessToken string) *MiniProgramAppCodeCreate
SetAccessToken SetAccessToken
func (*MiniProgramAppCodeCreate) SetMchID ¶
func (mpb *MiniProgramAppCodeCreate) SetMchID(mchID string) *MiniProgramAppCodeCreate
SetMchID SetMchID
func (*MiniProgramAppCodeCreate) SetOpenID ¶
func (mpb *MiniProgramAppCodeCreate) SetOpenID(openid string) *MiniProgramAppCodeCreate
SetOpenID SetOpenID
func (*MiniProgramAppCodeCreate) SetOutTradeNo ¶
func (mpb *MiniProgramAppCodeCreate) SetOutTradeNo(outTradeNo string) *MiniProgramAppCodeCreate
SetOutTradeNo SetOutTradeNo
func (*MiniProgramAppCodeCreate) SetTransactionID ¶
func (mpb *MiniProgramAppCodeCreate) SetTransactionID(transactionID string) *MiniProgramAppCodeCreate
SetTransactionID SetTransactionID
func (*MiniProgramAppCodeCreate) SetUsingTransID ¶
func (mpb *MiniProgramAppCodeCreate) SetUsingTransID() *MiniProgramAppCodeCreate
SetUsingTransID SetUsingTransID
func (*MiniProgramAppCodeCreate) Validate ¶
func (mpb *MiniProgramAppCodeCreate) Validate() error
Validate checks if the operation is valid.
type MiniProgramAppCodeCreateResponse ¶
type MiniProgramAppCodeCreateResponse struct { CommonError UnionID string `json:"unionid"` }
MiniProgramAppCodeCreateResponse MiniProgramAppCodeCreateResponse
type MiniProgramAppCodeGet ¶
type MiniProgramAppCodeGet struct {
// contains filtered or unexported fields
}
MiniProgramAppCodeGet MiniProgramAppCodeGet
func NewMiniProgramAppCodeGet ¶
func NewMiniProgramAppCodeGet(client *Client) *MiniProgramAppCodeGet
NewMiniProgramAppCodeGet return instance of NewMiniProgramAppCodeGet
func (*MiniProgramAppCodeGet) Do ¶
func (mpb *MiniProgramAppCodeGet) Do(ctx context.Context) (*MiniProgramAppCodeGetResponse, error)
Do Do
func (*MiniProgramAppCodeGet) SetAccessToken ¶
func (mpb *MiniProgramAppCodeGet) SetAccessToken(accessToken string) *MiniProgramAppCodeGet
SetAccessToken SetAccessToken
func (*MiniProgramAppCodeGet) SetMchID ¶
func (mpb *MiniProgramAppCodeGet) SetMchID(mchID string) *MiniProgramAppCodeGet
SetMchID SetMchID
func (*MiniProgramAppCodeGet) SetOpenID ¶
func (mpb *MiniProgramAppCodeGet) SetOpenID(openid string) *MiniProgramAppCodeGet
SetOpenID SetOpenID
func (*MiniProgramAppCodeGet) SetOutTradeNo ¶
func (mpb *MiniProgramAppCodeGet) SetOutTradeNo(outTradeNo string) *MiniProgramAppCodeGet
SetOutTradeNo SetOutTradeNo
func (*MiniProgramAppCodeGet) SetTransactionID ¶
func (mpb *MiniProgramAppCodeGet) SetTransactionID(transactionID string) *MiniProgramAppCodeGet
SetTransactionID SetTransactionID
func (*MiniProgramAppCodeGet) SetUsingTransID ¶
func (mpb *MiniProgramAppCodeGet) SetUsingTransID() *MiniProgramAppCodeGet
SetUsingTransID SetUsingTransID
func (*MiniProgramAppCodeGet) Validate ¶
func (mpb *MiniProgramAppCodeGet) Validate() error
Validate checks if the operation is valid.
type MiniProgramAppCodeGetResponse ¶
type MiniProgramAppCodeGetResponse struct { CommonError UnionID string `json:"unionid"` }
MiniProgramAppCodeGetResponse MiniProgramAppCodeGetResponse
type MiniProgramAppCodeGetUnlimit ¶
type MiniProgramAppCodeGetUnlimit struct {
// contains filtered or unexported fields
}
MiniProgramAppCodeGetUnlimit MiniProgramAppCodeGetUnlimit
func NewMiniProgramAppCodeGetUnlimit ¶
func NewMiniProgramAppCodeGetUnlimit(client *Client) *MiniProgramAppCodeGetUnlimit
NewMiniProgramAppCodeGetUnlimit return instance of NewMiniProgramAppCodeGetUnlimit
func (*MiniProgramAppCodeGetUnlimit) Do ¶
func (mpb *MiniProgramAppCodeGetUnlimit) Do(ctx context.Context) (*MiniProgramAppCodeGetUnlimitResponse, error)
Do Do
func (*MiniProgramAppCodeGetUnlimit) SetAccessToken ¶
func (mpb *MiniProgramAppCodeGetUnlimit) SetAccessToken(accessToken string) *MiniProgramAppCodeGetUnlimit
SetAccessToken SetAccessToken
func (*MiniProgramAppCodeGetUnlimit) SetMchID ¶
func (mpb *MiniProgramAppCodeGetUnlimit) SetMchID(mchID string) *MiniProgramAppCodeGetUnlimit
SetMchID SetMchID
func (*MiniProgramAppCodeGetUnlimit) SetOpenID ¶
func (mpb *MiniProgramAppCodeGetUnlimit) SetOpenID(openid string) *MiniProgramAppCodeGetUnlimit
SetOpenID SetOpenID
func (*MiniProgramAppCodeGetUnlimit) SetOutTradeNo ¶
func (mpb *MiniProgramAppCodeGetUnlimit) SetOutTradeNo(outTradeNo string) *MiniProgramAppCodeGetUnlimit
SetOutTradeNo SetOutTradeNo
func (*MiniProgramAppCodeGetUnlimit) SetTransactionID ¶
func (mpb *MiniProgramAppCodeGetUnlimit) SetTransactionID(transactionID string) *MiniProgramAppCodeGetUnlimit
SetTransactionID SetTransactionID
func (*MiniProgramAppCodeGetUnlimit) SetUsingTransID ¶
func (mpb *MiniProgramAppCodeGetUnlimit) SetUsingTransID() *MiniProgramAppCodeGetUnlimit
SetUsingTransID SetUsingTransID
func (*MiniProgramAppCodeGetUnlimit) Validate ¶
func (mpb *MiniProgramAppCodeGetUnlimit) Validate() error
Validate checks if the operation is valid.
type MiniProgramAppCodeGetUnlimitResponse ¶
type MiniProgramAppCodeGetUnlimitResponse struct { CommonError UnionID string `json:"unionid"` }
MiniProgramAppCodeGetUnlimitResponse MiniProgramAppCodeGetUnlimitResponse
type MiniProgramAuth ¶
type MiniProgramAuth struct {
// contains filtered or unexported fields
}
MiniProgramAuth mini program auth.
func NewMiniProgramAuth ¶
func NewMiniProgramAuth(client *Client) *MiniProgramAuth
NewMiniProgramAuth return instance of mini program auth
func (*MiniProgramAuth) Do ¶
func (mpa *MiniProgramAuth) Do(ctx context.Context) (*MiniProgramAuthResponse, error)
Do Do
func (*MiniProgramAuth) SetAppID ¶
func (mpa *MiniProgramAuth) SetAppID(appid string) *MiniProgramAuth
SetAppID SetAppID
func (*MiniProgramAuth) SetGrantType ¶
func (mpa *MiniProgramAuth) SetGrantType() *MiniProgramAuth
SetGrantType SetGrantType
func (*MiniProgramAuth) SetJscode ¶
func (mpa *MiniProgramAuth) SetJscode(jscode string) *MiniProgramAuth
SetJscode SetJscode
func (*MiniProgramAuth) SetSecret ¶
func (mpa *MiniProgramAuth) SetSecret(secret string) *MiniProgramAuth
SetSecret SetSecret
func (*MiniProgramAuth) Validate ¶
func (mpa *MiniProgramAuth) Validate() error
Validate checks if the operation is valid.
type MiniProgramAuthResponse ¶
type MiniProgramAuthResponse struct { CommonError AppID string `json:"openid"` SessionKey string `json:"session_key"` UnionID string `json:"unionid"` }
MiniProgramAuthResponse MiniProgramAuthResponse
type MiniProgramPaid ¶
type MiniProgramPaid struct {
// contains filtered or unexported fields
}
MiniProgramPaid MiniProgramPaid
func NewMiniProgramPaid ¶
func NewMiniProgramPaid(client *Client) *MiniProgramPaid
NewMiniProgramPaid return instance of NewMiniProgramPaid
func (*MiniProgramPaid) Do ¶
func (mpb *MiniProgramPaid) Do(ctx context.Context) (*MiniProgramPaidResponse, error)
Do Do
func (*MiniProgramPaid) SetAccessToken ¶
func (mpb *MiniProgramPaid) SetAccessToken(accessToken string) *MiniProgramPaid
SetAccessToken SetAccessToken
func (*MiniProgramPaid) SetMchID ¶
func (mpb *MiniProgramPaid) SetMchID(mchID string) *MiniProgramPaid
SetMchID SetMchID
func (*MiniProgramPaid) SetOpenID ¶
func (mpb *MiniProgramPaid) SetOpenID(openid string) *MiniProgramPaid
SetOpenID SetOpenID
func (*MiniProgramPaid) SetOutTradeNo ¶
func (mpb *MiniProgramPaid) SetOutTradeNo(outTradeNo string) *MiniProgramPaid
SetOutTradeNo SetOutTradeNo
func (*MiniProgramPaid) SetTransactionID ¶
func (mpb *MiniProgramPaid) SetTransactionID(transactionID string) *MiniProgramPaid
SetTransactionID SetTransactionID
func (*MiniProgramPaid) SetUsingTransID ¶
func (mpb *MiniProgramPaid) SetUsingTransID() *MiniProgramPaid
SetUsingTransID SetUsingTransID
func (*MiniProgramPaid) Validate ¶
func (mpb *MiniProgramPaid) Validate() error
Validate checks if the operation is valid.
type MiniProgramPaidResponse ¶
type MiniProgramPaidResponse struct { CommonError UnionID string `json:"unionid"` }
MiniProgramPaidResponse MiniProgramPaidResponse
type MiniProgramSecImg ¶
type MiniProgramSecImg struct {
// contains filtered or unexported fields
}
MiniProgramSecImg MiniProgramSecImg
func NewMiniProgramSecImg ¶
func NewMiniProgramSecImg(client *Client) *MiniProgramSecImg
NewMiniProgramSecImg return instance of NewMiniProgramSecImg
func (*MiniProgramSecImg) Do ¶
func (mpb *MiniProgramSecImg) Do(ctx context.Context) (*MiniProgramSecImgResponse, error)
Do Do
func (*MiniProgramSecImg) SetAccessToken ¶
func (mpb *MiniProgramSecImg) SetAccessToken(accessToken string) *MiniProgramSecImg
SetAccessToken SetAccessToken
func (*MiniProgramSecImg) SetMedia ¶
func (mpb *MiniProgramSecImg) SetMedia(media []byte) *MiniProgramSecImg
SetMedia SetMedia
func (*MiniProgramSecImg) Validate ¶
func (mpb *MiniProgramSecImg) Validate() error
Validate checks if the operation is valid.
type MiniProgramSecImgResponse ¶
type MiniProgramSecImgResponse struct {
CommonError
}
MiniProgramSecImgResponse MiniProgramSecImgResponse
type MiniProgramSecMsg ¶
type MiniProgramSecMsg struct {
// contains filtered or unexported fields
}
MiniProgramSecMsg MiniProgramSecMsg
func NewMiniProgramSecMsg ¶
func NewMiniProgramSecMsg(client *Client) *MiniProgramSecMsg
NewMiniProgramSecMsg return instance of NewMiniProgramSecMsg
func (*MiniProgramSecMsg) Do ¶
func (mpb *MiniProgramSecMsg) Do(ctx context.Context) (*MiniProgramSecMsgResponse, error)
Do Do
func (*MiniProgramSecMsg) SetAccessToken ¶
func (mpb *MiniProgramSecMsg) SetAccessToken(accessToken string) *MiniProgramSecMsg
SetAccessToken SetAccessToken
func (*MiniProgramSecMsg) SetMessage ¶
func (mpb *MiniProgramSecMsg) SetMessage(message string) *MiniProgramSecMsg
SetMessage SetMessage
func (*MiniProgramSecMsg) Validate ¶
func (mpb *MiniProgramSecMsg) Validate() error
Validate checks if the operation is valid.
type MiniProgramSecMsgResponse ¶
type MiniProgramSecMsgResponse struct {
CommonError
}
MiniProgramSecMsgResponse MiniProgramSecMsgResponse
type MiniProgramUniformMessage ¶
type MiniProgramUniformMessage struct { MsgBody *MiniProgramUniformMessageBody MsgParams url.Values }
MiniProgramUniformMessage MiniProgramUniformMessage
func NewMiniProgramUniformMessage ¶
func NewMiniProgramUniformMessage() *MiniProgramUniformMessage
NewMiniProgramUniformMessage NewMiniProgramUniformMessage
func (*MiniProgramUniformMessage) BaseURI ¶
func (mpum *MiniProgramUniformMessage) BaseURI() string
BaseURI BaseURI
func (*MiniProgramUniformMessage) Body ¶
func (mpum *MiniProgramUniformMessage) Body() interface{}
Body Body
func (*MiniProgramUniformMessage) Endpoint ¶
func (mpum *MiniProgramUniformMessage) Endpoint() string
Endpoint Endpoint
func (*MiniProgramUniformMessage) Params ¶
func (mpum *MiniProgramUniformMessage) Params() url.Values
Params Params
func (*MiniProgramUniformMessage) Validate ¶
func (mpum *MiniProgramUniformMessage) Validate() error
Validate Validate
type MiniProgramUniformMessageBody ¶
type MiniProgramUniformMessageBody struct { // 用户openid,可以是小程序的openid,也可以是mp_template_msg.appid对应的公众号的openid Touser string `json:"touser"` WeappTemplateMsg WeappTemplateMsg `json:"weapp_template_msg"` // 小程序模板消息相关的信息 MpTemplateMsg MpTemplateMsg `json:"mp_template_msg"` // 公众号模板消息相关的信息 }
MiniProgramUniformMessageBody MiniProgramUniformMessageBody
type MiniprogramContentItem ¶
MiniprogramContentItem MiniprogramContentItem
type MiniprogramNotice ¶
type MiniprogramNotice struct { Appid string `json:"appid"` Page string `json:"page"` Title string `json:"title"` Description string `json:"description"` EmphasisFirstItem bool `json:"emphasis_first_item"` ContentItem []MiniprogramContentItem `json:"content_item"` }
MiniprogramNotice MiniprogramNotice
type MpArticle ¶
type MpArticle struct { Title string `json:"title"` ThumbMediaID string `json:"thumb_media_id"` Author string `json:"author"` ContentSourceURL string `json:"content_source_url"` Content string `json:"content"` Digest string `json:"digest"` }
MpArticle MpArticle
type MpTemplateMsg ¶
type MpTemplateMsg struct { Appid string `json:"appid"` TemplateID string `json:"template_id"` URL string `json:"url"` Miniprogram struct { Appid string `json:"appid"` Pagepath string `json:"pagepath"` } `json:"miniprogram"` Data map[string]map[string]string `json:"data"` }
MpTemplateMsg MpTemplateMsg
type NumberDecoder ¶
type NumberDecoder struct{}
NumberDecoder uses json.NewDecoder, with UseNumber() enabled, from the Go standard library to decode JSON data.
func (*NumberDecoder) Decode ¶
func (u *NumberDecoder) Decode(data []byte, v interface{}) error
Decode decodes with json.Unmarshal from the Go standard library.
type OACustomImage ¶ added in v0.0.8
type OACustomImage struct {
MediaID string `json:"media_id"`
}
type OACustomMessage ¶ added in v0.0.7
type OACustomMessage struct { MsgBody *OACustomMessageBody MsgParams url.Values }
OACustomMessage 实现 IBasicMessage 接口
func NewOACustomMessage ¶ added in v0.0.7
func NewOACustomMessage(sm *OACustomMessage) *OACustomMessage
NewOACustomMessage 订阅消息
func (*OACustomMessage) BaseURI ¶ added in v0.0.7
func (mpum *OACustomMessage) BaseURI() string
BaseURI BaseURI
func (*OACustomMessage) Body ¶ added in v0.0.7
func (mpum *OACustomMessage) Body() interface{}
Body Body
func (*OACustomMessage) Endpoint ¶ added in v0.0.7
func (mpum *OACustomMessage) Endpoint() string
Endpoint Endpoint
func (*OACustomMessage) Params ¶ added in v0.0.7
func (mpum *OACustomMessage) Params() url.Values
Params Params
func (*OACustomMessage) Validate ¶ added in v0.0.7
func (mpum *OACustomMessage) Validate() error
Validate Validate
type OACustomMessageBody ¶ added in v0.0.7
type OACustomMessageBody struct { Touser string `json:"touser"` Msgtype string `json:"msgtype"` Miniprogrampage *OACustomMiniprogrampage `json:"miniprogrampage,omitempty"` Text *OACustomText `json:"text,omitempty"` Customservice *OACustomservice `json:"customservice,omitempty"` Wxcard *OACustomWXCard `json:"wxcard,omitempty"` Mpnews *OACustomMpnews `json:"mpnews,omitempty"` News *OACustomNews `json:"news,omitempty"` Music *OACustomMusic `json:"music,omitempty"` Voice *OACustomVoice `json:"voice,omitempty"` Video *OACustomVideo `json:"video,omitempty"` Image *OACustomImage `json:"image,omitempty"` }
OACustomMessageBody 消息体
type OACustomMiniprogrampage ¶ added in v0.0.8
type OACustomMpnews ¶ added in v0.0.8
type OACustomMpnews struct {
MediaID string `json:"media_id"`
}
type OACustomMsgmenu ¶ added in v0.0.8
type OACustomMusic ¶ added in v0.0.8
type OACustomNews ¶ added in v0.0.8
type OACustomText ¶ added in v0.0.8
type OACustomText struct {
Content string `json:"content"`
}
type OACustomVideo ¶ added in v0.0.8
type OACustomVoice ¶ added in v0.0.8
type OACustomVoice struct {
MediaID string `json:"media_id"`
}
type OACustomWXCard ¶ added in v0.0.8
type OACustomWXCard struct {
CardID string `json:"card_id"`
}
type OACustomservice ¶ added in v0.0.8
type OACustomservice struct {
KfAccount string `json:"kf_account"`
}
type OfficeAccountAccessToken ¶ added in v0.0.5
type OfficeAccountAccessToken struct {
// contains filtered or unexported fields
}
OfficeAccountAccessToken OfficeAccountAccessToken
func NewOfficeAccountAccessToken ¶ added in v0.0.5
func NewOfficeAccountAccessToken(client *Client) *OfficeAccountAccessToken
NewOfficeAccountAccessToken return instance of OfficeAccountAccessToken
func (*OfficeAccountAccessToken) Credentials ¶ added in v0.0.5
func (mpat *OfficeAccountAccessToken) Credentials(ctx context.Context) (*AccessToken, error)
Credentials Credentials
func (*OfficeAccountAccessToken) Do ¶ added in v0.0.5
func (mpat *OfficeAccountAccessToken) Do(ctx context.Context) (*OfficeAccountAccessTokenResponse, error)
Do Do
func (*OfficeAccountAccessToken) SetAppID ¶ added in v0.0.5
func (mpat *OfficeAccountAccessToken) SetAppID(appid string) *OfficeAccountAccessToken
SetAppID SetAppID
func (*OfficeAccountAccessToken) SetGrantType ¶ added in v0.0.5
func (mpat *OfficeAccountAccessToken) SetGrantType() *OfficeAccountAccessToken
SetGrantType SetGrantType
func (*OfficeAccountAccessToken) SetSecret ¶ added in v0.0.5
func (mpat *OfficeAccountAccessToken) SetSecret(secret string) *OfficeAccountAccessToken
SetSecret SetSecret
func (*OfficeAccountAccessToken) ToString ¶ added in v0.0.5
func (mpat *OfficeAccountAccessToken) ToString() string
ToString ToString
func (*OfficeAccountAccessToken) Validate ¶ added in v0.0.5
func (mpat *OfficeAccountAccessToken) Validate() error
Validate checks if the operation is valid.
type OfficeAccountAccessTokenResponse ¶ added in v0.0.5
type OfficeAccountAccessTokenResponse struct { CommonError AccessToken string `json:"access_token"` ExpiresIn int64 `json:"expires_in"` }
OfficeAccountAccessTokenResponse OfficeAccountAccessTokenResponse
type PerformRequestOptions ¶
type PerformRequestOptions struct { Method string Params url.Values Body interface{} FormValue []byte FormFieldName string FormFileName string ContentType string IgnoreErrors []int Headers http.Header MaxResponseSize int64 BaseURI string Endpoint string }
PerformRequestOptions must be passed into PerformRequest.
type Request ¶
Request Wechat-specific HTTP request
func NewRequest ¶
NewRequest is a http.Request and adds features such as encoding the body.
type Response ¶
type Response struct { // StatusCode is the HTTP status code, e.g. 200. StatusCode int // Header is the HTTP header from the HTTP response. // Keys in the map are canonicalized (see http.CanonicalHeaderKey). Header http.Header // Body is the deserialized response body. Body json.RawMessage }
Response represents a response from wechat.
type Taskcard ¶
type Taskcard struct { Title string `json:"title"` Description string `json:"description"` URL string `json:"url"` TaskID string `json:"task_id"` Btn []TaskcardBtn `json:"btn"` }
Taskcard Taskcard
type TaskcardBtn ¶
type TaskcardBtn struct { Key string `json:"key"` Name string `json:"name"` ReplaceName string `json:"replace_name"` Color string `json:"color,omitempty"` IsBold bool `json:"is_bold,omitempty"` }
TaskcardBtn TaskcardBtn
type Textcard ¶
type Textcard struct { Title string `json:"title"` Description string `json:"description"` URL string `json:"url"` Btntxt string `json:"btntxt"` }
Textcard Textcard
type Video ¶
type Video struct { MediaID string `json:"media_id"` Title string `json:"title"` Description string `json:"description"` }
Video Video
type WXBizDataCrypt ¶
type WXBizDataCrypt struct {
// contains filtered or unexported fields
}
WXBizDataCrypt WXBizDataCrypt
func NewWXBizDataCrypt ¶
func NewWXBizDataCrypt(appID, sessionKey string) *WXBizDataCrypt
NewWXBizDataCrypt NewWXBizDataCrypt
func (*WXBizDataCrypt) Decrypt ¶
func (w *WXBizDataCrypt) Decrypt(encryptedData, iv string, data interface{}) error
Decrypt Decrypt
type WeappTemplateMsg ¶
type WeappTemplateMsg struct { TemplateID string `json:"template_id"` Page string `json:"page"` FormID string `json:"form_id"` Data map[string]struct { Value string `json:"value"` } `json:"data"` EmphasisKeyword string `json:"emphasis_keyword"` }
WeappTemplateMsg WeappTemplateMsg
type WorkAccessToken ¶
type WorkAccessToken struct {
// contains filtered or unexported fields
}
WorkAccessToken WorkAccessToken
func NewWorkAccessToken ¶
func NewWorkAccessToken(client *Client) *WorkAccessToken
NewWorkAccessToken return instance of WorkAccessToken
func (*WorkAccessToken) Credentials ¶
func (wat *WorkAccessToken) Credentials(ctx context.Context) (*AccessToken, error)
Credentials Credentials
func (*WorkAccessToken) Do ¶
func (wat *WorkAccessToken) Do(ctx context.Context) (*WorkAccessTokenResponse, error)
Do Do
func (*WorkAccessToken) SetAgentID ¶
func (wat *WorkAccessToken) SetAgentID(agentid string) *WorkAccessToken
SetAgentID SetAgentID
func (*WorkAccessToken) SetAppID ¶
func (wat *WorkAccessToken) SetAppID(corpid string) *WorkAccessToken
SetAppID SetAppID
func (*WorkAccessToken) SetSecret ¶
func (wat *WorkAccessToken) SetSecret(corpsecret string) *WorkAccessToken
SetSecret SetSecret
func (*WorkAccessToken) Validate ¶
func (wat *WorkAccessToken) Validate() error
Validate checks if the operation is valid.
type WorkAccessTokenResponse ¶
type WorkAccessTokenResponse struct { CommonError AccessToken string `json:"access_token"` ExpiresIn int64 `json:"expires_in"` }
WorkAccessTokenResponse WorkAccessTokenResponse
type WorkAppMessage ¶
type WorkAppMessage struct { MsgBody *WorkAppMessageBody MsgParams url.Values }
WorkAppMessage WorkAppMessage
func NewWorkAppMessage ¶
func NewWorkAppMessage() *WorkAppMessage
NewWorkAppMessage NewWorkAppMessage
type WorkAppMessageBody ¶
type WorkAppMessageBody struct { Touser string `json:"touser"` Toparty string `json:"toparty"` Totag string `json:"totag"` Msgtype string `json:"msgtype"` Agentid int `json:"agentid"` Safe int `json:"safe,omitempty"` Textcard *Textcard `json:"textcard,omitempty"` Text *Text `json:"text,omitempty"` Image *Image `json:"image,omitempty"` Voice *Voice `json:"voice,omitempty"` Video *Video `json:"video,omitempty"` File *File `json:"file,omitempty"` News *News `json:"news,omitempty"` Mpnews *Mpnews `json:"mpnews,omitempty"` Markdown *Markdown `json:"markdown,omitempty"` MiniprogramNotice *MiniprogramNotice `json:"miniprogram_notice,omitempty"` Taskcard *Taskcard `json:"taskcard,omitempty"` }
WorkAppMessageBody WorkAppMessageBody
type XMLDecoder ¶
type XMLDecoder struct{}
XMLDecoder uses xml.NewDecoder from the Go standard library to decode XML data.
func (*XMLDecoder) Decode ¶
func (u *XMLDecoder) Decode(data []byte, v interface{}) error
Decode decodes with json.Unmarshal from the Go standard library.
Source Files ¶
- basic.go
- basic_accesstoken.go
- basic_message.go
- cache.go
- client.go
- client_funcs.go
- decoder.go
- encryptor.go
- errcode.go
- errors.go
- logger.go
- miniprogram_accesstoken.go
- miniprogram_appcode.go
- miniprogram_auth.go
- miniprogram_msg_activity.go
- miniprogram_msg_subscribe.go
- miniprogram_msg_uniform.go
- miniprogram_paid.go
- miniprogram_sec_img.go
- miniprogram_sec_msg.go
- officeaccount_accesstoken.go
- officeaccount_msg_custom.go
- request.go
- response.go
- work_accesstoken.go
- work_app_message.go