Documentation ¶
Overview ¶
Package wechat provide wechat sdk for go
使用Golang开发的微信SDK,简单、易用。
以下是一个处理消息接收以及回复的例子:
//配置微信参数 config := &wechat.Config{ AppID: "xxxx", AppSecret: "xxxx", Token: "xxxx", EncodingAESKey: "xxxx", } wc := wechat.NewWechat(config) // 传入request和responseWriter server := wc.GetServer(request, responseWriter) server.SetMessageHandler(func(msg message.MixMessage) *message.Reply { //回复消息:演示回复用户发送的消息 text := message.NewText(msg.Content) return &message.Reply{message.MsgText, text} }) server.Serve() server.Send()
Index ¶
- type Config
- type Wechat
- func (wc *Wechat) GetAccessToken() (string, error)
- func (wc *Wechat) GetDevice() *device.Device
- func (wc *Wechat) GetJs() *js.Js
- func (wc *Wechat) GetMaterial() *material.Material
- func (wc *Wechat) GetMenu() *menu.Menu
- func (wc *Wechat) GetMiniProgram() *miniprogram.MiniProgram
- func (wc *Wechat) GetOauth() *oauth.Oauth
- func (wc *Wechat) GetOpen() *open.Open
- func (wc *Wechat) GetPay() *pay.Pay
- func (wc *Wechat) GetQR() *qr.QR
- func (wc *Wechat) GetServer(req *http.Request, writer http.ResponseWriter) *server.Server
- func (wc *Wechat) GetTcb() *tcb.Tcb
- func (wc *Wechat) GetTemplate() *message.Template
- func (wc *Wechat) GetUser() *user.User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { AppID string // 小程序/平台 appid AppSecret string // 小程序/平台secret Token string // 消息校验token EncodingAESKey string // 消息加解密key PayMchID string // 支付 - 商户 ID PayNotifyURL string // 支付 - 接受微信支付结果通知的接口地址 PayKey string // 支付 - 商户后台设置的支付 key P12 []byte // 支付 - 商户证书文件 Cache cache.Cache }
Config for user
type Wechat ¶
Wechat struct
func (*Wechat) GetAccessToken ¶
GetAccessToken 获取access_token
func (*Wechat) GetMiniProgram ¶
func (wc *Wechat) GetMiniProgram() *miniprogram.MiniProgram
GetMiniProgram 获取小程序的实例
Click to show internal directories.
Click to hide internal directories.