小程序審核因為內容安全性風險審核不通過。提示如下:
為避免您的小程序被濫用,請你完善內容審核機制,如調用小程序內容安全API,或使用其他技術、人工審核手段,過濾色情、違法等有害信息,保障發(fā)布內容的安全。
分享一下我的解決方案(云開發(fā)版)
config.json
{
"permissions": {
"openapi": [
"security.msgSecCheck"
]
}
}
云函數
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
const { content } = event;
try {
var res = ''
//一次傳多個文本,如果有一個不過審,返回審核不通過
for (var i = 0; i < event.content.length; i++) {
res = await cloud.openapi.security.msgSecCheck({
content: event.content[i]
})
if (res.errCode == '87014') {
return res;
}
}
return res;
} catch (err) {
return err;
}
}
js
//校驗文字是否合法
wx.cloud.callFunction({
name: 'checkMsgs',
data: {
content: [a, b]
},
success: function (res) {
if (res.result.errCode == '87014') {
wx.showToast({
title: '含有違法違規(guī)內容',
icon: 'none'
})
return;
}
},
fail: function (res) {
console.error;
return;
}
})
長期廣告:我在開發(fā)中遇到的更多的坑都已經記錄在easyDemo小程序中,希望我的demo能給你easy。我還會持續(xù)更新easyDemo,歡迎收藏。

easyDemo.jpg