接口请求示例图
安装依赖
npm i tls-sig-api-v2
使用源码
'use strict';
const Controller = require('egg').Controller;
let TLSSigAPIv2 = require('tls-sig-api-v2');
class tencentImController extends Controller {
async genSin() {
const { ctx } = this;
var api = new TLSSigAPIv2.Api(1400000000, '5bd2850fff3ecb11d7c805251c51ee463a25727bddc2385f3fa8bfee1bb93b5e');
var sig = api.genSig(ctx.query.userId, 86400 * 180);
ctx.body = {
code: 200,
data: sig,
};
}
}
module.exports = tencentImController;
接口请求
router.get('/api/genSin/', controller.tencentIm.genSin);