bbyte

1、需要购买ocr服务:https://developers.weixin.qq.com/community/servicemarket/detail/000ce4cec24ca026d37900ed551415

2、购买时需要选择是小程序还是公众号,根据应用场景选,然后授权当前使用的小程序或公众号;

3、在小程序需要识别的地方添加以下代码:

wx.serviceMarket.invokeService({
      service: \'wx79ac3de8be320b71\', // \'固定为服务商OCR的appid,非小程序appid\',
      api: \'OcrAllInOne\',
      data: {
        img_url: "图片地址,如:http://www.example.com/xxx.jpg",
        data_type: 3,
        ocr_type: 1,
      },
    }).then(res => {
      console.log(\'invokeService success\', res)
      wx.showModal({
        title: \'cost\',
        content: (Date.now() - 5) + \'\',
      })
    }).catch(err => {
      console.error(\'invokeService fail\', err)
      wx.showModal({
        title: \'fail\',
        content: err + \'\',
      })
    })
  }

 4、明细请看接入文档

分类:

技术点:

相关文章: