package
1.0.0
Repository: https://github.com/ericjsanchez/wecom.git
Documentation: pkg.go.dev

# README

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 := "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
	corpSecret := "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
	rsaPrivateKey := `XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`

	//初始化客户端
	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{}
			for !isFinish {
				//获取媒体数据
				mediaData, err := client.GetMediaData("", sdkfileid, "", "", 5)
				if err != nil {
					fmt.Printf("媒体数据拉取失败:%v \n", err)
					return
				}
				buffer.Write(mediaData.Data)
				if mediaData.IsFinish {
					isFinish = mediaData.IsFinish
				}
			}
			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
		}
	}
}



# Packages

No description provided by the author

# Functions

NewClient new.
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

返回码 错误说明10000 参数错误,请求参数错误10001 网络错误,网络请求错误10002 数据解析失败10003 系统失败10004 密钥错误导致加密失败10005 fileid错误10006 解密失败10007 找不到消息加密版本的私钥,需要重新传入私钥对10008 解析encrypt_key出错10009 ip非法10010 数据过期10011 证书错误.
返回码 错误说明10000 参数错误,请求参数错误10001 网络错误,网络请求错误10002 数据解析失败10003 系统失败10004 密钥错误导致加密失败10005 fileid错误10006 解密失败10007 找不到消息加密版本的私钥,需要重新传入私钥对10008 解析encrypt_key出错10009 ip非法10010 数据过期10011 证书错误.
返回码 错误说明10000 参数错误,请求参数错误10001 网络错误,网络请求错误10002 数据解析失败10003 系统失败10004 密钥错误导致加密失败10005 fileid错误10006 解密失败10007 找不到消息加密版本的私钥,需要重新传入私钥对10008 解析encrypt_key出错10009 ip非法10010 数据过期10011 证书错误.
返回码 错误说明10000 参数错误,请求参数错误10001 网络错误,网络请求错误10002 数据解析失败10003 系统失败10004 密钥错误导致加密失败10005 fileid错误10006 解密失败10007 找不到消息加密版本的私钥,需要重新传入私钥对10008 解析encrypt_key出错10009 ip非法10010 数据过期10011 证书错误.
返回码 错误说明10000 参数错误,请求参数错误10001 网络错误,网络请求错误10002 数据解析失败10003 系统失败10004 密钥错误导致加密失败10005 fileid错误10006 解密失败10007 找不到消息加密版本的私钥,需要重新传入私钥对10008 解析encrypt_key出错10009 ip非法10010 数据过期10011 证书错误.
返回码 错误说明10000 参数错误,请求参数错误10001 网络错误,网络请求错误10002 数据解析失败10003 系统失败10004 密钥错误导致加密失败10005 fileid错误10006 解密失败10007 找不到消息加密版本的私钥,需要重新传入私钥对10008 解析encrypt_key出错10009 ip非法10010 数据过期10011 证书错误.
返回码 错误说明10000 参数错误,请求参数错误10001 网络错误,网络请求错误10002 数据解析失败10003 系统失败10004 密钥错误导致加密失败10005 fileid错误10006 解密失败10007 找不到消息加密版本的私钥,需要重新传入私钥对10008 解析encrypt_key出错10009 ip非法10010 数据过期10011 证书错误.
返回码 错误说明10000 参数错误,请求参数错误10001 网络错误,网络请求错误10002 数据解析失败10003 系统失败10004 密钥错误导致加密失败10005 fileid错误10006 解密失败10007 找不到消息加密版本的私钥,需要重新传入私钥对10008 解析encrypt_key出错10009 ip非法10010 数据过期10011 证书错误.
返回码 错误说明10000 参数错误,请求参数错误10001 网络错误,网络请求错误10002 数据解析失败10003 系统失败10004 密钥错误导致加密失败10005 fileid错误10006 解密失败10007 找不到消息加密版本的私钥,需要重新传入私钥对10008 解析encrypt_key出错10009 ip非法10010 数据过期10011 证书错误.
返回码 错误说明10000 参数错误,请求参数错误10001 网络错误,网络请求错误10002 数据解析失败10003 系统失败10004 密钥错误导致加密失败10005 fileid错误10006 解密失败10007 找不到消息加密版本的私钥,需要重新传入私钥对10008 解析encrypt_key出错10009 ip非法10010 数据过期10011 证书错误.
返回码 错误说明10000 参数错误,请求参数错误10001 网络错误,网络请求错误10002 数据解析失败10003 系统失败10004 密钥错误导致加密失败10005 fileid错误10006 解密失败10007 找不到消息加密版本的私钥,需要重新传入私钥对10008 解析encrypt_key出错10009 ip非法10010 数据过期10011 证书错误.
返回码 错误说明10000 参数错误,请求参数错误10001 网络错误,网络请求错误10002 数据解析失败10003 系统失败10004 密钥错误导致加密失败10005 fileid错误10006 解密失败10007 找不到消息加密版本的私钥,需要重新传入私钥对10008 解析encrypt_key出错10009 ip非法10010 数据过期10011 证书错误.
返回码 错误说明10000 参数错误,请求参数错误10001 网络错误,网络请求错误10002 数据解析失败10003 系统失败10004 密钥错误导致加密失败10005 fileid错误10006 解密失败10007 找不到消息加密版本的私钥,需要重新传入私钥对10008 解析encrypt_key出错10009 ip非法10010 数据过期10011 证书错误.

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Client 会话存档.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author