• Stars
    star
    268
  • Rank 153,144 (Top 4 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

企业微信会话存档SDK(基于企业微信C版官方SDK封装)

WeWorkFinanceSDK

企业微信会话存档SDK(基于企业微信C版官方SDK封装),暂时只支持在linux环境下使用当前SDK。

官方文档地址

https://open.work.weixin.qq.com/api/doc/90000/90135/91774

使用方式

1、安装 go module

go get -u github.com/NICEXAI/WeWorkFinanceSDK

2、从 github.com/NICEXAI/WeWorkFinanceSDK/lib 文件夹下复制 libWeWorkFinanceSdk_C.so 动态库文件到系统动态链接库默认文件夹下,或者复制到任意文件夹并在当前文件夹下执行 export LD_LIBRARY_PATH=$(pwd)命令设置动态链接库检索地址

3、把 module 引入到项目中即可使用

Example

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
		}
	}
}

More Repositories

1

leaflet_zh

Leaflet 中文网
HTML
1,536
star
2

figma-i18n

Powerful, intelligent and easy to use Figma internationalisation scripts.
TypeScript
140
star
3

WeChatCustomerServiceSDK

微信客服SDK
Go
128
star
4

ghost

An annotation-based template engine.
Go
73
star
5

fstask

Go
43
star
6

go2struct

Convert arbitrary formats to Go Struct (including json, toml, yaml, etc.)
Go
37
star
7

go-rmonitor

An easy-to-use go service resource monitor, support containers.
Go
6
star
8

lazy-go

lazy-go is an easy-to-use WEB framework.
Go
5
star
9

quick-comment

Tampermonkey script for quick comment on CSDN
JavaScript
3
star
10

NICEXAI

3
star
11

go-limiter

Easy-to-use distributed multi-function current limiter.
Go
3
star
12

excel_kit

An easy-to-use excel kit.
Dart
3
star
13

go-program-tuning

Simple tuning work for go programs in high concurrency scenarios.
Go
3
star
14

flesch-go

Go-based implementation of the Flesch reading ease readability formula module.
Go
2
star
15

ts2interface

Convert arbitrary formats to Typescript Interface(including json, toml, yaml, etc.)
TypeScript
2
star
16

go-eventbus

Lightweight, highly available and versatile eventbus.
Go
1
star
17

command

exec-based command tools.
Go
1
star
18

NICEXAI.github.io

HTML
1
star
19

go-workspace-example

Go
1
star
20

lazy-scaffold-node-base

用于 lazy-go 的基础 node 初始化项目,集成了 TS、Docker、Eslint、Prettier等常用组件
TypeScript
1
star
21

lazy-scaffold-api

Go
1
star
22

graceful-exit

Graceful exit for golang project.
Go
1
star
23

react-textarea-mentions

Textarea mentions component for react.
TypeScript
1
star
24

go2struct-tool

Use the command to convert arbitrary formats to Go Struct (including json, toml, yaml, etc.)
Go
1
star