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

Liangwt fe31f04640 增加微信公众号数据统计功能 (#279) před 6 roky
.github d91d1dd630 add workflow:memcached service před 6 roky
aispeech 15ebd71a04 规范目录 před 6 roky
cache 2af3f42055 增加SetRedisPool方法 (#265) před 6 roky
credential 58092a21de testCase:使用gock模拟http接口数据 před 6 roky
minigame 85b0a114dc rebase release-2.0 před 6 roky
miniprogram fe31f04640 增加微信公众号数据统计功能 (#279) před 6 roky
officialaccount fe31f04640 增加微信公众号数据统计功能 (#279) před 6 roky
openplatform 3d7d60644f 开发平台,将GetServer单独提取 (#273) před 6 roky
pay 340e1a3c5b merge #221 před 6 roky
util 15ebd71a04 规范目录 před 6 roky
work 15ebd71a04 规范目录 před 6 roky
.gitignore 15ebd71a04 规范目录 před 6 roky
LICENSE f3303e2bb3 Initial commit před 9 roky
README.md 2ccc15b050 Add 贡献者 (#274) před 6 roky
doc.go 15ebd71a04 规范目录 před 6 roky
go.mod 58092a21de testCase:使用gock模拟http接口数据 před 6 roky
go.sum 5e8e16444c 群发消息接口 (#259) před 6 roky
wechat.go 340e1a3c5b merge #221 před 6 roky

README.md

WeChat SDK for Go

Go Go Report Card pkg

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

当前版本为2.0版本

文档 && 例子

Wechat SDK 2.0 文档

Wechat SDK 2.0 例子

快速开始

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

//使用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:智能对话

贡献

  • 提交issue,描述需要贡献的内容
  • 完成更改后,提交PR

感谢以下成员贡献.

公众号

img

License

Apache License, Version 2.0