Giter VIP home page Giter VIP logo

wechat's Introduction

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

wechat's People

Contributors

silenceper avatar nicexai avatar markwang1992 avatar airylinus avatar cielu avatar larryclean avatar ckeyer avatar houseme avatar greatwhole avatar amorist avatar waro163 avatar okhowang avatar akikistyle avatar lilien1010 avatar ackerr avatar zdpdpdp avatar aikangs avatar narrowizard avatar wgjtyu avatar forrestsu avatar dguang21 avatar cxjhk avatar youkjw avatar holdno avatar yueyue1zhe avatar lnnt avatar save95 avatar publicpwd avatar kaiiak avatar just5325 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.