微信OCR识别报错err_code -8,如何更正?
微信OCR识别 服务已经购买,按API示例代码调用报错
Uncaught (in promise) thirdScriptError
invokeService:fail operateWXData:fail (err_code -8)
Error: invokeService:fail operateWXData:fail (err_code -8)
appid
wx4e66f7295c676531
app.json
"plugins": {
"ocr-plugin": {
"version": "3.0.2",
"provider": "wx4418e3e031e551be"
}
},
page.json
{
"navigationBarTitleText": "请拍摄身份证",
"usingComponents": {
"ocr-navigator": "plugin://ocr-plugin/ocr-navigator"
}
}
page.js 调用实例代码
// 点击拍照按钮
takePhoto() {
const ctx = wx.createCameraContext();
// 获取camera实时帧数据
const listener = ctx.onCameraFrame((frame) => {
//如果不需要则注释掉
});
// 实拍照片配置
ctx.takePhoto({
quality: 'high',//成像质量
success: async (res) => {
const invokeRes = await wx.serviceMarket.invokeService({
service: 'wx4418e3e031e551be',
api: 'OcrAllInOne',
data: {
// 用 CDN 方法标记要上传并转换成 HTTP URL 的文件
img_url: new wx.serviceMarket.CDN({
type: 'filePath',
filePath: res.tempImagePath,
}),
data_type: 3,
ocr_type: 1
},
})
console.log(invokeRes);
this.setData({
src: res.tempImagePath,//tempImagePath为api返回的照片路径
show: true
});
},
fail: (error) => {//失败回调
sys.catch('获取照片失败', error);
}
});
},