微信被投诉,微信小程序敏感内容检测
第一步:获取access_token//获取access_tokenletaccess_token=wx.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}}})第二步:敏感文本检测开发者服务器可以调用此接口校验一段文本是否含有敏感信息。接口为https://api.weixin.qq.com/wxa/msg_sec_check?access_token=ACCESS_TOKEN示例代码:letaccess_token=wx.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){//合格}}})第三步:敏感图片检测开发者服务器可以调用此接口校验一张图片是否含有敏感信息。接口为https://api.weixin.qq.com/wxa/img_sec_check?access_token=ACCESS_TOKEN示例代码:注意⚠️:一定要设置header头部信息'Content-Type':'application/octet-stream'letaccess_token=wx.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"}}})
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

