第一步:获取access_token

//获取access_token  let access_token = wx.getStorageSync('access_token');  if (access_token != null){    //直接进行检测操作  }  let url = '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

示例代码:

 let access_token = wx.getStorageSync('access_token');  let url = '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内含有敏感信息,则返回87014      if (res.errcode !== 87014) {           // 合格       }    }  })

第三步:敏感图片检测

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

https://api.weixin.qq.com/wxa/img_sec_check?access_token=ACCESS_TOKEN

示例代码:

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

 let access_token = wx.getStorageSync('access_token');  let url = '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-103119.html