Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) AccessToken(ctx context.Context) (gjson.Result, error)
- func (c *Client) AppID() string
- func (c *Client) Code2Session(ctx context.Context, code string) (gjson.Result, error)
- func (*Client) DecodeEncryptData(sessionKey, iv, encryptData string) ([]byte, error)
- func (c *Client) DecodeEventMsg(encrypt string) ([]byte, error)
- func (c *Client) EncodeEventReply(msg string) (KV, error)
- func (c *Client) R() *Request
- func (c *Client) Secret() string
- func (c *Client) SetAesKey(sn, key string)
- func (c *Client) SetHttpClient(cli *http.Client)
- func (c *Client) SetLogger(fn func(ctx context.Context, err error, data map[string]string))
- func (c *Client) SetPrivateKey(pem []byte) error
- func (c *Client) SetPrivateKeyFromPfx(pfxData []byte, password string) error
- func (c *Client) SetPublicKey(pem []byte) error
- func (c *Client) SetServerConfig(token, aeskey string)
- func (c *Client) SetTokenLoader(fn func(ctx context.Context) (string, error))
- func (c *Client) StableAccessToken(ctx context.Context, forceRefresh bool) (gjson.Result, error)
- func (c *Client) VerifyEventMsg(signature string, items ...string) error
- type KV
- type Request
- func (r *Request) BufferGet(ctx context.Context, path string) ([]byte, error)
- func (r *Request) BufferPost(ctx context.Context, path string) ([]byte, error)
- func (r *Request) EncryptBufferPost(ctx context.Context, path string) ([]byte, error)
- func (r *Request) EncryptPost(ctx context.Context, path string) (gjson.Result, error)
- func (r *Request) Get(ctx context.Context, path string) (gjson.Result, error)
- func (r *Request) Post(ctx context.Context, path string) (gjson.Result, error)
- func (r *Request) SetBody(body X) *Request
- func (r *Request) SetFile(param, filename string, reader io.Reader) *Request
- func (r *Request) SetForm(k, v string) *Request
- func (r *Request) SetHeader(k string, vs ...string) *Request
- func (r *Request) SetQuery(k string, vs ...string) *Request
- func (r *Request) Upload(ctx context.Context, path string) (gjson.Result, error)
- type SafeMode
- type ServerConfig
- type X
Constants ¶
View Source
const ( HeaderAppID = "Wechatmp-Appid" HeaderTimestamp = "Wechatmp-TimeStamp" HeaderSerial = "Wechatmp-Serial" HeaderSignature = "Wechatmp-Signature" HeaderSerialDeprecated = "Wechatmp-Serial-Deprecated" HeaderSignatureDeprecated = "Wechatmp-Signature-Deprecated" )
View Source
const AccessToken = "access_token"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 小程序
func (*Client) AccessToken ¶
AccessToken 获取接口调用凭据
func (*Client) Code2Session ¶
Code2Session 通过临时登录凭证code完成登录流程
func (*Client) DecodeEncryptData ¶
DecodeEncryptData 解析加密数据,如:授权的用户信息和手机号
[参考](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html)
func (*Client) DecodeEventMsg ¶
DecodeEventMsg 事件消息解密
使用包体内的 Encrypt 字段 根据配置的数据格式,解析 XML/JSON [参考](https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/message-push.html)
func (*Client) EncodeEventReply ¶
EncodeEventReply 事件回复加密
根据配置的数据格式,输出 XML/JSON [参考](https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/message-push.html)
func (*Client) SetHttpClient ¶
func (*Client) SetPrivateKey ¶
func (*Client) SetPrivateKeyFromPfx ¶
func (*Client) SetPublicKey ¶
func (*Client) SetServerConfig ¶
SetServerConfig 设置服务器配置
[参考](https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/message-push.html)
func (*Client) SetTokenLoader ¶
func (*Client) StableAccessToken ¶
StableAccessToken 获取稳定版接口调用凭据
有两种调用模式: [普通模式] access_token有效期内重复调用该接口不会更新access_token,绝大部分场景下使用该模式; [强制刷新模式] 会导致上次获取的access_token失效,并返回新的access_token
func (*Client) VerifyEventMsg ¶
VerifyEventMsg 验证事件消息
[服务器URL验证] URL参数中的 signature、timestamp、nonce 注意:验证成功后,原样返回 echostr 字段值 [事件消息验证] [明文模式] URL参数中的 signature、timestamp、nonce [安全模式] URL参数中的 msg_signature、timestamp、nonce 和包体内的 Encrypt 字段 [参考](https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/message-push.html)
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func (*Request) BufferPost ¶
BufferPost 获取 buffer (如:获取二维码)
func (*Request) EncryptBufferPost ¶
EncryptBufferPost 加密获取 buffer (如:获取二维码)
[安全鉴权模式](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/getting_started/api_signature.html) [支持的API](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc)
func (*Request) EncryptPost ¶
EncryptPost 加密请求
[安全鉴权模式](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/getting_started/api_signature.html) [支持的API](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc)
type SafeMode ¶
type SafeMode struct {
// contains filtered or unexported fields
}
SafeMode 安全鉴权模式配置
type ServerConfig ¶
type ServerConfig struct {
// contains filtered or unexported fields
}
ServerConfig 服务器配置
Click to show internal directories.
Click to hide internal directories.