微信小程序-敏感内容检测-小程序如何安全测试-小程序安全测试
第一步:获取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"}}})声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

