mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-04 12:52:27 +08:00
docs:更新会话存档README.md文件内的示例代码 (#527)
This commit is contained in:
@@ -34,13 +34,13 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
//初始化客户端
|
//初始化客户端
|
||||||
wechatClient := wechat.NewWechat()
|
wechatClient := wechat.NewWechat()
|
||||||
|
|
||||||
workClient := wechatClient.GetWork(&config.Config{
|
workClient := wechatClient.GetWork(&config.Config{
|
||||||
CorpID: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
CorpID: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
||||||
CorpSecret: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
CorpSecret: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
||||||
RasPrivateKey: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
RasPrivateKey: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
|
||||||
})
|
})
|
||||||
|
|
||||||
client, err := workClient.GetMsgAudit()
|
client, err := workClient.GetMsgAudit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("SDK 初始化失败:%v \n", err)
|
fmt.Printf("SDK 初始化失败:%v \n", err)
|
||||||
@@ -64,13 +64,14 @@ func main() {
|
|||||||
|
|
||||||
if chatInfo.Type == "image" {
|
if chatInfo.Type == "image" {
|
||||||
image, _ := chatInfo.GetImageMessage()
|
image, _ := chatInfo.GetImageMessage()
|
||||||
sdkfileid := image.Image.SdkFileID
|
sdkFileID := image.Image.SdkFileID
|
||||||
|
|
||||||
isFinish := false
|
isFinish := false
|
||||||
buffer := bytes.Buffer{}
|
buffer := bytes.Buffer{}
|
||||||
|
indexBuf := ""
|
||||||
for !isFinish {
|
for !isFinish {
|
||||||
//获取媒体数据
|
//获取媒体数据
|
||||||
mediaData, err := client.GetMediaData("", sdkfileid, "", "", 5)
|
mediaData, err := client.GetMediaData(indexBuf, sdkFileID, "", "", 5)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("媒体数据拉取失败:%v \n", err)
|
fmt.Printf("媒体数据拉取失败:%v \n", err)
|
||||||
return
|
return
|
||||||
@@ -79,6 +80,7 @@ func main() {
|
|||||||
if mediaData.IsFinish {
|
if mediaData.IsFinish {
|
||||||
isFinish = mediaData.IsFinish
|
isFinish = mediaData.IsFinish
|
||||||
}
|
}
|
||||||
|
indexBuf = mediaData.OutIndexBuf
|
||||||
}
|
}
|
||||||
filePath, _ := os.Getwd()
|
filePath, _ := os.Getwd()
|
||||||
filePath = path.Join(filePath, "test.png")
|
filePath = path.Join(filePath, "test.png")
|
||||||
@@ -90,11 +92,11 @@ func main() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//释放SDK实例
|
//释放SDK实例
|
||||||
client.Free()
|
client.Free()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
Reference in New Issue
Block a user