第一步:获取access_token//获取access_tokenletaccess_tokenwx.getStorageSync('access_token');if(access_token!null){//直接进行检测操作}leturl'https://api.weixin.qq.com/cgi-bin/token';wx.request({url:url,method:'GET',data:{grant_type:'client_credential',appid:'小程序的appid',secret:'小程序的appsecret'},success:function(res){console.log(res);//正常返回结果//{"access_token":"ACCESS_TOKEN","expires_in":7200}}})第二步:敏感文本检测1.

开发者服务器可以调用此接口校验一段文本是否含有敏感信息。接口为

https://api.weixin.qq.com/wxa/msg_sec_check?access_tokenACCESS_TOKEN2.

示例代码:

letaccess_tokenwx.getStorageSync('access_token');leturl'https://api.weixin.qq.com/wxa/msg_sec_check?access_token'+access_token;wx.request({url:url,method:'POST',data:{content:文本内容},success:function(res){//当content内含有敏感信息,则返回87014if(res.errcode!87014){//合格}}})第三步:敏感图片检测3.

开发者服务器可以调用此接口校验一张图片是否含有敏感信息。接口为

https://api.weixin.qq.com/wxa/img_sec_check?access_tokenACCESS_TOKEN4.

示例代码:

5.

注意⚠️:一定要设置header头部信息'Content-Type':'application/octet-stream'

letaccess_tokenwx.getStorageSync('access_token');leturl'https://api.weixin.qq.com/wxa/img_sec_check?access_token'+access_token;wx.request({url:url,method:'POST',header:{'Content-Type':'application/octet-stream'},data:{media:formData},success:function(res){console.log(res);//{"errcode":0,"errmsg":"ok"}}})

TAG标签: 微信小程序敏感内容检测小程序如何安全测试小程序安全测试

http://www.xiaochengxub.com/read-96113.html