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

wby 80ce4aefc4 微信小程序新版获取手机号授权接口 (#528) 4 vuotta sitten
.github e068d53dcb Create release.yml 4 vuotta sitten
aispeech 15ebd71a04 规范目录 6 vuotta sitten
cache d3d91b8d29 实例化Redis新增dialOpts参数以支持redis更多拨号设置 (#475) 4 vuotta sitten
credential 96c1f98944 [feature] Format the code and improve Mini Program authorization to o… (#473) 4 vuotta sitten
doc f5f401e76c doc: 更新微信客服 API 文档 (#495) 4 vuotta sitten
minigame 85b0a114dc rebase release-2.0 6 vuotta sitten
miniprogram 80ce4aefc4 微信小程序新版获取手机号授权接口 (#528) 4 vuotta sitten
officialaccount 8c87c49f2a update: 统一消息类型 (#511) 4 vuotta sitten
openplatform 172c4abde5 通过component_verify_ticket 获取 ComponentAccessToken 错误处理 (#521) 4 vuotta sitten
pay f74869e61c Transfer to wallet returns pointer object (#489) 4 vuotta sitten
util 1e2f909f34 小程序auth增加Context接口 (#483) 4 vuotta sitten
work 0d915d203b docs:更新会话存档README.md文件内的示例代码 (#527) 4 vuotta sitten
.gitignore c8522f1875 小程序内容安全 (#415) 5 vuotta sitten
.golangci.yml c0da806e03 update golangci (#349) 5 vuotta sitten
.goreleaser.yml 83e223999b add .goreleaser.yml 4 vuotta sitten
LICENSE f3303e2bb3 Initial commit 9 vuotta sitten
README.md 83621a38c6 Update README.md 4 vuotta sitten
doc.go 15ebd71a04 规范目录 6 vuotta sitten
go.mod 4721f7567b 支持微信小程序隐私接口 (#518) 4 vuotta sitten
go.sum 96c1f98944 [feature] Format the code and improve Mini Program authorization to o… (#473) 4 vuotta sitten
wechat.go 96c1f98944 [feature] Format the code and improve Mini Program authorization to o… (#473) 4 vuotta sitten

README.md

WeChat SDK for Go

Go Go Report Card pkg version

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

注意:当前版本为v2版本,v1版本已废弃

文档 && 例子

API列表

Wechat SDK 2.0 文档

Wechat SDK 2.0 例子

快速开始

import "github.com/silenceper/wechat/v2"

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

//使用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
  • openplatform:开放平台API
  • work:企业微信
  • aispeech:智能对话
  • doc: api文档

贡献

  • API列表中查看哪些API未实现
  • 提交issue,描述需要贡献的内容
  • 完成更改后,提交PR

公众号

img

License

Apache License, Version 2.0