WeWorkFinanceSDK
v1.3.0
SDK pengarsipan percakapan Enterprise WeChat (berdasarkan paket SDK resmi versi Enterprise WeChat C) saat ini hanya mendukung penggunaan SDK saat ini di lingkungan linux
.
https://open.work.weixin.qq.com/api/doc/90000/90135/91774
1. Instal modul go
dapatkan -u github.com/NICEXAI/WeWorkFinanceSDK
2. Salin file perpustakaan dinamis libWeWorkFinanceSdk_C.so
dari folder github.com/NICEXAI/WeWorkFinanceSDK/lib
ke folder default perpustakaan tautan dinamis sistem, atau salin ke folder mana pun dan jalankan perintah export LD_LIBRARY_PATH=$(pwd)
untuk mengatur alamat pencarian perpustakaan tautan dinamis
3. Perkenalkan module
ke dalam proyek dan gunakan
package main
import (
"bytes"
"fmt"
"github.com/NICEXAI/WeWorkFinanceSDK"
"io/ioutil"
"os"
"path"
)
func main () {
corpID := "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
corpSecret := "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
rsaPrivateKey := `
-----BEGIN RSA PRIVATE KEY-----
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-----END RSA PRIVATE KEY-----
`
//初始化客户端
client , err := WeWorkFinanceSDK . NewClient ( corpID , corpSecret , rsaPrivateKey )
if err != nil {
fmt . Printf ( "SDK 初始化失败:%v n " , err )
return
}
//同步消息
chatDataList , err := client . GetChatData ( 0 , 100 , "" , "" , 3 )
if err != nil {
fmt . Printf ( "消息同步失败:%v n " , err )
return
}
for _ , chatData := range chatDataList {
//消息解密
chatInfo , err := client . DecryptData ( chatData . EncryptRandomKey , chatData . EncryptChatMsg )
if err != nil {
fmt . Printf ( "消息解密失败:%v n " , err )
return
}
if chatInfo . Type == "image" {
image := chatInfo . GetImageMessage ()
sdkfileid := image . Image . SdkFileID
isFinish := false
buffer := bytes. Buffer {}
index_buf := ""
for ! isFinish {
//获取媒体数据
mediaData , err := client . GetMediaData ( index_buf , sdkfileid , "" , "" , 5 )
if err != nil {
fmt . Printf ( "媒体数据拉取失败:%v n " , err )
return
}
buffer . Write ( mediaData . Data )
if mediaData . IsFinish {
isFinish = mediaData . IsFinish
}
index_buf = mediaData . OutIndexBuf
}
filePath , _ := os . Getwd ()
filePath = path . Join ( filePath , "test.png" )
err := ioutil . WriteFile ( filePath , buffer . Bytes (), 0666 )
if err != nil {
fmt . Printf ( "文件存储失败:%v n " , err )
return
}
break
}
}
}