wechat

package module
v2.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 13 Imported by: 79

README

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

Documentation

Overview

Package wechat provide wechat sdk for go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Wechat

type Wechat struct {
	// contains filtered or unexported fields
}

Wechat struct

func NewWechat

func NewWechat() *Wechat

NewWechat init

func (*Wechat) GetMiniProgram

func (wc *Wechat) GetMiniProgram(cfg *miniConfig.Config) *miniprogram.MiniProgram

GetMiniProgram 获取小程序的实例

func (*Wechat) GetOfficialAccount

func (wc *Wechat) GetOfficialAccount(cfg *offConfig.Config) *officialaccount.OfficialAccount

GetOfficialAccount 获取微信公众号实例

func (*Wechat) GetOpenPlatform

func (wc *Wechat) GetOpenPlatform(cfg *openConfig.Config) *openplatform.OpenPlatform

GetOpenPlatform 获取微信开放平台的实例

func (*Wechat) GetPay

func (wc *Wechat) GetPay(cfg *payConfig.Config) *pay.Pay

GetPay 获取微信支付的实例

func (*Wechat) GetWork added in v2.0.7

func (wc *Wechat) GetWork(cfg *workConfig.Config) *work.Work

GetWork 获取企业微信的实例

func (*Wechat) SetCache

func (wc *Wechat) SetCache(cache cache.Cache)

SetCache 设置 cache

Directories

Path Synopsis
domain
internal
config
Package config 小程序 config 配置
Package config 小程序 config 配置
minidrama
Package minidrama Mini Program entertainment mini-drama related interface
Package minidrama Mini Program entertainment mini-drama related interface
tcb
virtualpayment
Package virtualpayment mini program virtual payment
Package virtualpayment mini program virtual payment
device
Package device 设备相关接口
Package device 设备相关接口
js
ocr
user
Package user blacklist 公众号用户黑名单管理 参考文档:https://developers.weixin.qq.com/doc/offiaccount/User_Management/Manage_blacklist.html
Package user blacklist 公众号用户黑名单管理 参考文档:https://developers.weixin.qq.com/doc/offiaccount/User_Management/Manage_blacklist.html
context
Package context 开放平台相关context
Package context 开放平台相关context
pay
appchat
Package appchat 应用发送消息到群聊会话,企业微信接口:https://developer.work.weixin.qq.com/document/path/90248
Package appchat 应用发送消息到群聊会话,企业微信接口:https://developer.work.weixin.qq.com/document/path/90248
config
Package config 企业微信config配置
Package config 企业微信config配置
kf
message
Package message 消息推送,实现企业微信消息推送相关接口:https://developer.work.weixin.qq.com/document/path/90235
Package message 消息推送,实现企业微信消息推送相关接口:https://developer.work.weixin.qq.com/document/path/90235
msgaudit
Package msgaudit for unsupport platform
Package msgaudit for unsupport platform

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL