wechat

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

README

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

Documentation

Overview

Package wechat provide wechat sdk for go

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

更多信息:https://github.com/xiya-vip/wechat

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	PayMchID     string //支付 - 商户 ID
	PayNotifyURL string //支付 - 接受微信支付结果通知的接口地址
	PayKey       string //支付 - 商户后台设置的支付 key
}

Config for user

type Wechat

type Wechat struct {
}

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) GetPay

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

GetPay 获取微信支付的实例

Jump to

Keyboard shortcuts

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