ocr.businessLicense
本接口应在服务器端调用,详细说明参见 服务端API。
10年积累的网站设计、网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站策划后付款的网站建设流程,更有利州免费网站建设让你可以放心的选择与我们合作。
本接口支持 云调用。需开发者工具版本 >= 1.02.1904090(最新 稳定版下载)
wx-server-sdk >= 0.4.0
本接口提供基于小程序的营业执照 OCR 识别
调用方式:
- HTTPS 调用
- 云调用
HTTPS 调用
请求地址
POST https://api.weixin.qq.com/cv/ocr/bizlicense?img_url=ENCODE_URL&access_token=ACCESS_TOCKEN
请求参数
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| access_token | string | 是 | 接口调用凭证 | |
| img_url | string | 是 | 要检测的图片 url,传这个则不用传 img 参数。 | |
| img | FormData | 是 | form-data 中媒体文件标识,有filename、filelength、content-type等信息,传这个则不用传 img_url。 |
返回值
Object
返回的 JSON 数据包
| 属性 | 类型 | 说明 |
|---|---|---|
| errcode | string | 错误码 |
| errmsg | string | 错误信息 |
| reg_num | string | 注册号 |
| serial | string | 编号 |
| legal_representative | string | 法定代表人姓名 |
| enterprise_name | string | 企业名称 |
| type_of_organization | string | 组成形式 |
| address | string | 经营场所/企业住所 |
| type_of_enterprise | string | 公司类型 |
| business_scope | string | 经营范围 |
| registered_capital | string | 注册资本 |
| paid_in_capital | string | 实收资本 |
| valid_period | string | 营业期限 |
| registered_date | string | 注册日期/成立日期 |
| cert_position | string | 营业执照位置 |
| img_size | string | 图片大小 |
使用说明
接口限制 内测期间已认证的订阅号、服务号、企业号、小程序可直接调用,次数限制为500次/天。
使用 Tips 此接口为后台接口,可基于自有业务承载情况,搭配小程序的拍照、相册选照等一起使用,即可完成身份证照片的采集、上传、识别、信息返回等流程,用于需要基于身份证、银行卡等实体卡或证,采集照片或文字信息等的业务场景。
图片说明 文件大小限制:小于2M
返回字段仅包含当前营业执照图片中存在的字段,若对应字段不存在则不返回
拍摄图片样例
请求数据示例
示例1:
curl https://api.weixin.qq.com/cv/ocr/bizlicense?img_url= ENCODE_URL&access_token=ACCESS_TOCKEN
示例2:
curl -F ‘img=@test.jpg’“https://api.weixin.qq.com/cv/ocr/bizlicense?access_token=ACCESS_TOCKEN”
返回数据示例
{
"errcode": 0,
"errmsg": "ok",
"reg_num": "123123", //注册号
"serial": "123123", //编号
"legal_representative": "张三", //法定代表人姓名
"enterprise_name": "XX饮食店", //企业名称
"type_of_organization": "个人经营", //组成形式
"address": "XX市XX区XX路XX号", //经营场所/企业住所
"type_of_enterprise": "xxx", //公司类型
"business_scope": "中型餐馆(不含凉菜、不含裱花蛋糕,不含生食海产品)。", //经营范围
"registered_capital": "200万", //注册资本
"paid_in_capital": "200万", //实收资本
"valid_period": "2019年1月1日", //营业期限
"registered_date": "2018年1月1日", //注册日期/成立日期
"cert_position": { //营业执照位置
"pos": {
"left_top": {
"x": 155,
"y": 191
},
"right_top": {
"x": 725,
"y": 157
},
"right_bottom": {
"x": 743,
"y": 512
},
"left_bottom": {
"x": 164,
"y": 525
}
}
},
"img_size": { //图片大小
"w": 966,
"h": 728
}
}
云调用
云调用是小程序·云开发提供的在云函数中调用微信开放接口的能力,需要在云函数中通过 wx-server-sdk 使用。
接口方法
openapi.ocr.businessLicense
需在 config.json 中配置 ocr.businessLicense API 的权限, 详情
请求参数
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| imgUrl | string | 是 | 要检测的图片 url,传这个则不用传 img 参数。 | |
| img | FormData | 是 | form-data 中媒体文件标识,有filename、filelength、content-type等信息,传这个则不用传 img_url。 |
img 的结构
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| contentType | string | 是 | 数据类型,传入 MIME Type | |
| value | Buffer | 是 | 文件 Buffer |
返回值
Object
返回的 JSON 数据包
| 属性 | 类型 | 说明 |
|---|---|---|
| errCode | string | 错误码 |
| errMsg | string | 错误信息 |
| regNum | string | 注册号 |
| serial | string | 编号 |
| legalRepresentative | string | 法定代表人姓名 |
| enterpriseName | string | 企业名称 |
| typeOfOrganization | string | 组成形式 |
| address | string | 经营场所/企业住所 |
| typeOfEnterprise | string | 公司类型 |
| businessScope | string | 经营范围 |
| registeredCapital | string | 注册资本 |
| paidInCapital | string | 实收资本 |
| validPeriod | string | 营业期限 |
| registeredDate | string | 注册日期/成立日期 |
| certPosition | string | 营业执照位置 |
| imgSize | string | 图片大小 |
异常
Object
抛出的异常
| 属性 | 类型 | 说明 |
|---|---|---|
| errCode | string | 错误码 |
| errMsg | string | 错误信息 |
errCode 的合法值
| 值 | 说明 | 最低版本 |
|---|
使用说明
接口限制 内测期间已认证的订阅号、服务号、企业号、小程序可直接调用,次数限制为500次/天。
使用 Tips 此接口为后台接口,可基于自有业务承载情况,搭配小程序的拍照、相册选照等一起使用,即可完成身份证照片的采集、上传、识别、信息返回等流程,用于需要基于身份证、银行卡等实体卡或证,采集照片或文字信息等的业务场景。
图片说明 文件大小限制:小于2M
返回字段仅包含当前营业执照图片中存在的字段,若对应字段不存在则不返回
拍摄图片样例
请求数据示例
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.ocr.businessLicense({
imgUrl: 'ENCODE_URL'
})
return result
} catch (err) {
return err
}
}
或
// cloud = require('wx-server-sdk')
// ...
// 方法返回 Promise
cloud.openapi.ocr.businessLicense({
img: {
contentType: 'image/png',
value: Buffer
}
})
返回数据示例
{
"errcode": 0,
"errmsg": "ok",
"reg_num": "123123", //注册号
"serial": "123123", //编号
"legal_representative": "张三", //法定代表人姓名
"enterprise_name": "XX饮食店", //企业名称
"type_of_organization": "个人经营", //组成形式
"address": "XX市XX区XX路XX号", //经营场所/企业住所
"type_of_enterprise": "xxx", //公司类型
"business_scope": "中型餐馆(不含凉菜、不含裱花蛋糕,不含生食海产品)。", //经营范围
"registered_capital": "200万", //注册资本
"paid_in_capital": "200万", //实收资本
"valid_period": "2019年1月1日", //营业期限
"registered_date": "2018年1月1日", //注册日期/成立日期
"cert_position": { //营业执照位置
"pos": {
"left_top": {
"x": 155,
"y": 191
},
"right_top": {
"x": 725,
"y": 157
},
"right_bottom": {
"x": 743,
"y": 512
},
"left_bottom": {
"x": 164,
"y": 525
}
}
},
"img_size": { //图片大小
"w": 966,
"h": 728
}
} 分享标题:创新互联小程序教程:微信小程序OCR·businessLicense
地址分享:http://www.jxjierui.cn/article/cosgcgg.html


咨询
建站咨询

