openplatform

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

微信开放平台

官方文档

快速入门

服务端处理
wc := wechat.NewWechat()
memory := cache.NewMemory()
cfg := &openplatform.Config{
    AppID:     "xxx",
    AppSecret: "xxx",
    Token:     "xxx",
    EncodingAESKey: "xxx",
    Cache: memory,
}


openPlatform := wc.GetOpenPlatform(cfg)
// 传入request和responseWriter
server := openPlatform.GetServer(req, rw)
//设置接收消息的处理方法
server.SetMessageHandler(func(msg message.MixMessage) *message.Reply {
    if msg.InfoType == message.InfoTypeVerifyTicket {
        componentVerifyTicket, err := openPlatform.SetComponentAccessToken(msg.ComponentVerifyTicket)
        if err != nil {
            log.Println(err)
            return nil
        }
        //debug 
        fmt.Println(componentVerifyTicket)
        rw.Write([]byte("success"))
        return nil
    }
    //handle other message
    //
    
    
    return nil
})

//处理消息接收以及回复
err := server.Serve()
if err != nil {
    fmt.Println(err)
    return
}
//发送回复的消息
server.Send()


待授权处理消息

//授权的第三方公众号的appID
appID := "xxx"
openPlatform := wc.GetOpenPlatform(cfg)
openPlatform.GetOfficialAccount(appID)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OpenPlatform

type OpenPlatform struct {
	*context.Context
}

OpenPlatform 微信开放平台相关api

func NewOpenPlatform

func NewOpenPlatform(cfg *config.Config) *OpenPlatform

NewOpenPlatform new openplatform

func (*OpenPlatform) GetAccountManager

func (openPlatform *OpenPlatform) GetAccountManager() *account.Account

GetAccountManager 账号管理 TODO

func (*OpenPlatform) GetMiniProgram

func (openPlatform *OpenPlatform) GetMiniProgram(appID string) *miniprogram.MiniProgram

GetMiniProgram 小程序代理

func (*OpenPlatform) GetOfficialAccount

func (openPlatform *OpenPlatform) GetOfficialAccount(appID string) *officialaccount.OfficialAccount

GetOfficialAccount 公众号代处理

func (*OpenPlatform) GetServer

func (openPlatform *OpenPlatform) GetServer(c *gin.Context, appID string) *server.Server

GetServer get server

Directories

Path Synopsis
js

Jump to

Keyboard shortcuts

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