WeChat SDK for Go (微信SDK:简单、易用)

silenceper 51cbfab087 待处理小程序业务 6 yıl önce
.github 431f7d3a9f Update FUNDING.yml 6 yıl önce
aispeech 15ebd71a04 规范目录 6 yıl önce
cache 3984f13c76 add memory cache 7 yıl önce
minigame 7e8c94a6c4 开放平台基本框架 6 yıl önce
miniprogram 7e8c94a6c4 开放平台基本框架 6 yıl önce
officialaccount 51cbfab087 待处理小程序业务 6 yıl önce
openplatform 51cbfab087 待处理小程序业务 6 yıl önce
pay 15ebd71a04 规范目录 6 yıl önce
util 15ebd71a04 规范目录 6 yıl önce
work 15ebd71a04 规范目录 6 yıl önce
.gitignore 15ebd71a04 规范目录 6 yıl önce
.travis.yml 19e3174107 Update .travis.yml 6 yıl önce
LICENSE f3303e2bb3 Initial commit 9 yıl önce
README.md 15ebd71a04 规范目录 6 yıl önce
doc.go 15ebd71a04 规范目录 6 yıl önce
go.mod 15ebd71a04 规范目录 6 yıl önce
go.sum 15ebd71a04 规范目录 6 yıl önce
wechat.go 7e8c94a6c4 开放平台基本框架 6 yıl önce

README.md

WeChat SDK for Go

Build Status Go Report Card GoDoc

使用Golang开发的微信SDK,简单、易用。

快速开始

以下是一个微信公众号处理消息接收以及回复的例子:

//使用memcache保存access_token,也可选择redis或自定义cache
wc := wechat.NewWechat()
memory := cache.NewMemory()
cfg := &offConfig.Config{
    AppID:     "xxx",
    AppSecret: "xxx",
    Token:     "xxx",
    //EncodingAESKey: "xxxx",
    Cache: memory,
}
officialAccount := wc.GetOfficialAccount(cfg)

// 传入request和responseWriter
server := officialAccount.GetServer(req, rw)
//设置接收消息的处理方法
server.SetMessageHandler(func(msg message.MixMessage) *message.Reply {

    //回复消息:演示回复用户发送的消息
    text := message.NewText(msg.Content)
    return &message.Reply{MsgType: message.MsgTypeText, MsgData: text}
})

//处理消息接收以及回复
err := server.Serve()
if err != nil {
    fmt.Println(err)
    return
}
//发送回复的消息
server.Send()

参与贡献

目录说明

  • officialaccount: 微信公众号API
  • miniprogram: 小程序API
  • minigame:小游戏API
  • pay:微信支付API
  • opernplatform:开放平台API
  • work:企业微信
  • aispeech:智能对话

交流群:

关注公众号入群交流

关注公众号并回复“入群”

License

Apache License, Version 2.0