mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-08 14:42:26 +08:00
开发平台,将GetServer单独提取 (#273)
* 添加TODO:待完善接口 * 【模板消息】将message.DataItem改为message.TemplateDataItem * fix PKG.DEV * 增加一个 SetRedisPool 方法 * fix:模板消息推送增加一个TemplateMsgID * fix 开放平台服务端处理
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
## 快速入门
|
||||
|
||||
### 服务端处理
|
||||
```go
|
||||
wc := wechat.NewWechat()
|
||||
memory := cache.NewMemory()
|
||||
@@ -16,13 +17,10 @@ cfg := &openplatform.Config{
|
||||
Cache: memory,
|
||||
}
|
||||
|
||||
//授权的第三方公众号的appID
|
||||
appID := "xxx"
|
||||
openPlatform := wc.GetOpenPlatform(cfg)
|
||||
officialAccount := openPlatform.GetOfficialAccount(appID)
|
||||
|
||||
openPlatform := wc.GetOpenPlatform(cfg)
|
||||
// 传入request和responseWriter
|
||||
server := officialAccount.GetServer(req, rw)
|
||||
server := openPlatform.GetServer(req, rw)
|
||||
//设置接收消息的处理方法
|
||||
server.SetMessageHandler(func(msg message.MixMessage) *message.Reply {
|
||||
if msg.InfoType == message.InfoTypeVerifyTicket {
|
||||
@@ -51,4 +49,15 @@ if err != nil {
|
||||
}
|
||||
//发送回复的消息
|
||||
server.Send()
|
||||
|
||||
|
||||
```
|
||||
### 待授权处理消息
|
||||
```go
|
||||
|
||||
//授权的第三方公众号的appID
|
||||
appID := "xxx"
|
||||
openPlatform := wc.GetOpenPlatform(cfg)
|
||||
openPlatform.GetOfficialAccount(appID)
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user