small 2020-05-29
wx.request({ url: ‘https://api.weixin.qq.com/cgi-bin/token‘, method : ‘GET‘, data : { grant_type: ‘client_credential‘, appid: ‘小程序的appid ‘, secret: ‘小程序的appsecret ‘ }, success : function(res){ console.log(res); //正常返回结果 //{"access_token":"ACCESS_TOKEN","expires_in":7200} } })
wx.request({ url: ‘https://api.weixin.qq.com/wxa/msg_sec_checkaccess_token=‘+access_token, method: ‘POST‘, data: { content: 文本内容 }, success: function (res) { //当content内含有敏感信息,则返回87014 if (res.data.errcode !== 87014) { // 合格 } } })
let tempFilePaths = res.tempFilePaths; wx.uploadFile({ url: ‘https://api.weixin.qq.com/wxa/img_sec_check?access_token=‘ + accesstoken, method: ‘POST‘, filePath: tempFilePaths[i], name: ‘file‘, header: { ‘Content-Type‘: ‘application/octet-stream‘ //一定要设置header头部信息’Content-Type’: ‘application/octet-stream’ }, formData: { media: tempFilePaths[i] }, success: function(res) { if (JSON.parse(res.data).errcode === 87014) { uni.showModal({ content: ‘图片中含有内含有敏感信息,禁止上传‘, showCancel: false, }); } }, })