增加百度和微信内容审核接口

This commit is contained in:
zhl 2021-06-16 13:27:07 +08:00
parent 928d2b06dc
commit 90a001675f
3 changed files with 21 additions and 10 deletions

View File

@ -21,12 +21,13 @@ class GameController extends BaseController {
// let sessionId = '1622783517_1556611531_60838f020d9c51716f144bf7a71b2af5_e5818d3fc90f8491aa285246cb6d85ce'
// let result = await getInviteeNum(accountId, sessionId, [1001])
// return result
const { txt } = req.params
// const { txt } = req.params
// const res = await checkText(txt)
// const token = await refreshToken('wxf8c3da4e7dfe00a2', '8c0a1e88a6b43e4be80ed6a597c0b047')
// return { token }
const { data } = await msgSecCheck(txt)
return { data }
// // const token = await refreshToken('wxf8c3da4e7dfe00a2', '8c0a1e88a6b43e4be80ed6a597c0b047')
// // return { token }
// const { data } = await msgSecCheck(txt)
// return { baidu: res.data, wx: data }
return {}
}
@permission(['game:read', 'shop:game_setting'])
@router('post /api/games')

View File

@ -28,9 +28,7 @@ export async function checkText(txt: string) {
'User-Agent': useragent,
'X-Forwarded-For': getIp(),
},
responseType: 'json',
data: data,
}
const res = await axios(reqConfig)
return res
return axios(reqConfig)
}

View File

@ -27,10 +27,17 @@ export async function generateQr({ appId, appSecret, scene, file }) {
return true
}
export async function refreshToken(appId: string, appSecret: string) {
/**
* api的access token
* @param {string} appId
* @param {string} appSecret
* @param {boolean} refresh
* @return {Promise<any>}
*/
export async function refreshToken(appId: string, appSecret: string, refresh: boolean = false) {
const util = new WxTokenCache()
let token = util.getToken(appId)
if (token) {
if (token && !refresh) {
return token
}
const link = `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${appId}&secret=${appSecret}`
@ -43,6 +50,11 @@ export async function refreshToken(appId: string, appSecret: string) {
}
}
/**
* security.msgSecCheck接口检查违法违规内容
* @param {string} content
* @return {AxiosPromise<any>}
*/
export async function msgSecCheck(content: string) {
let data = { content }
const token = await refreshToken('wxf8c3da4e7dfe00a2', '8c0a1e88a6b43e4be80ed6a597c0b047')