微信小程序> 微信小程序-敏感内容检测-小程序如何安全测试-小程序安全测试

微信小程序-敏感内容检测-小程序如何安全测试-小程序安全测试

浏览量:2218 时间: 来源:chibimarukochan
第一步:获取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"}}})

版权声明

即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。

产品经理

手机 : 13312967497

擅长 : 小程序流量变现

扫码领取礼包

最新资讯

热门模板

  • 头条
  • 搜狐
  • 微博
  • 百家
  • 一点资讯
  • 知乎