theodore ded5a10f9f 小程序服务商 - 获取 URL Link 及 查询小程序 url_link 配置 (#576) 4 jaren geleden
..
account 96c1f98944 [feature] Format the code and improve Mini Program authorization to o… (#473) 4 jaren geleden
config 96c1f98944 [feature] Format the code and improve Mini Program authorization to o… (#473) 4 jaren geleden
context c6325ace85 补充获取授权方帐号基本信息中小程序相关信息 (#573) 4 jaren geleden
miniprogram ded5a10f9f 小程序服务商 - 获取 URL Link 及 查询小程序 url_link 配置 (#576) 4 jaren geleden
officialaccount 96c1f98944 [feature] Format the code and improve Mini Program authorization to o… (#473) 4 jaren geleden
README.md 8e81a416c5 Adaptation of new go-redis components (#546) 4 jaren geleden
openplatform.go 96c1f98944 [feature] Format the code and improve Mini Program authorization to o… (#473) 4 jaren geleden

README.md

微信开放平台

官方文档

快速入门

服务端处理

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)