1.0.12 • Published 1 year ago

ms-qywx-chat v1.0.12

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

ms-qywx-chat


企业微信会话存档, 适用于mac, linux, windows等系统, 使用前需要提前安装node-gyp, 建议使用node-gyp@9.3.1版本。

安装


安装示例:

npm install ms-qywx-chat

示例

1、查询企微聊天消息 getData(seq, limit, timeout, corpid, secret)

  • seq, 从指定的seq开始拉取消息,注意的是返回的消息从seq+1开始返回,seq为之前接口返回的最大seq值。首次使用请使用seq:0 。Number类型
  • limit, 一次拉取的消息条数,最大值1000条,超过1000条会返回错误。Number类型
  • timeout, 超时时间,单位秒。Number类型
  • corpid, 调用企业的企业id, 可以在企业微信管理端--我的企业--企业信息查看。String类型
  • secret, 聊天内容存档的Secret, 可以在企业微信管理端--管理工具--聊天内容存档查看。String类型。
// 引用
const qywxChat = require('ms-qywx-chat');

/**
 * 获取消息
 * 参数解释:
 * seq, 从指定的seq开始拉取消息,注意的是返回的消息从seq+1开始返回,seq为之前接口返回的最大seq值。首次使用请使用seq:0
 * limit, 一次拉取的消息条数,最大值1000条,超过1000条会返回错误
 * timeout, 超时时间,单位秒
 * corpid, 调用企业的企业id, 可以在企业微信管理端--我的企业--企业信息查看
 * secret, 聊天内容存档的Secret, 可以在企业微信管理端--管理工具--聊天内容存档查看
 */
let seq = 0;
let limit = 10;
let timeout = 60;
let corpid = 'xxxx corpid xxxx';
let secret = 'xxxx secret xxxx';
const message = qywxChat.getData(seq, limit, timeout, corpid, secret);
console.log('message:', message);

2、查询媒体消息 getMediaData(sdkfileid, timeout, filepath, corpid, secret)

  • sdkfileid, 媒体资源的id信息。String类型
  • timeout, 超时时长。 Number类型
  • filepath, 媒体文件本地保存路径。String类型
  • corpid, 企业ID。String类型
  • secret, 存档 Secret。String类型
// 引用
const qywxChat = require('ms-qywx-chat');
const path = require('path');

let sdkfileid = 'CtYBMzA2OTAyMDEwMjA0NjIzMDYwMDIwMTAwMDIwNDY5MjhhNTAwMDIwMzBmNDI0MTAyMDQzNmMxNmViNDAyMDQ2NDNmM2Q0Z...';
let timeout = 60;
let filepath = path.join(__dirname, 'temp.png');
let corpid = 'xxxx corpid xxxx';
let secret = 'xxxx secret xxxx';
const mediaMessage = qywxChat.getMediaData(sdkfileid, timeout, filepath, corpid, secret);
console.log('mediaMessage:', mediaMessage);

3、解密消息 decryptData(decrypt_random_key, encrypt_chat_msg)

  • decrypt_random_key, getData返回的encrypt_random_key,使用企业自持对应版本私钥RSA解密后的内容。String类型
  • encrypt_chat_msg, getchatdata返回的encrypt_chat_msg。String类型
// 引用
const qywxChat = require('ms-qywx-chat');

let decrypt_random_key = 'xxxx ...';
let encrypt_chat_msg = 'yyyy ...';
const decryptMessage = qywxChat.decryptData(decrypt_random_key, encrypt_chat_msg);
console.log('decryptMessage:', decryptMessage);

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago