“多证合一”的政策使得营业执照成为企业唯一的身份标识,并且营业执照的格式和内容逐渐标准化。这为 OCR 识别技术应用于营业执照信息识别提供了有利条件,降低了识别的难度,提高了识别的准确性。
信息公开与共享政策为营业执照 OCR 识别后的信息核验提供了可靠的数据源,进一步推动了 OCR 识别技术在营业执照领域的应用。
以下是PHP实现营业执照OCR识别API接口的示例代码:
<?php$appKey = "您的appKey";
$appSecret= "您的appSecret";$url = "https://api.shuxuntech.com/v1/business/ocr";
$method = "POST";$timestamp = getUnixTimestamp();
var_dump($timestamp);
$sign = hash('sha256',$appKey . $timestamp . $appSecret);
var_dump($sign);$headers = array();
array_push($headers, "Content-Type" . ":" . "application/x-www-form-urlencoded; charset=UTF-8");
array_push($headers, "appKey" . ":" . appKey);
array_push($headers, "timestamp" . ":" . timestamp);
array_push($headers, "sign" . ":" . sign);$image = "";
$imgUrl = "";
$bodys = "image=" . $image . "&imgUrl=" . $imgUrl;$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);if (1 == strpos("$".$url, "https://")) {curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
var_dump(curl_exec($curl));function getUnixTimestamp () {list($s1, $s2) = explode(' ', microtime());return sprintf('%.0f',(floatval($s1) + floatval($s2)) * 1000);
}
返回的数据:
(1)正确返回:
"code": "0","msg": "成功","isFee": 1,"seqNo": "98ik48a942udag92uxvhz1jw2txplza9","data": {"result": 1,"resultDesc": "识别成功,有数据","info": {"enterpriseType": "有限责任公司(自然人独资)","address": "浙江省杭州市余杭区五常街道瑞谷中心7幢5层525-7室","registrationCapital": "壹佰万元整","opTo": "","orgForm": "","opScope": "一般项目:技术服务、技术开发、技术咨询、技术交流、技术转让、技术推广:信息系统集成服务:大数据服务:软件开发;数字内容制作服务(不含出版发行):互联网数据服务:网络与信息安全软件开发:人工智能公共数据平台:信息技术咨询服务:数据处理服务:计算机系统服务:企业管理咨询:计算机软硬件及辅助设备批发:计算机软硬件及辅助设备零售:电子产品销售;通讯设备销售:互联网销售(除销售需要许可的商品)(除依法须经批准的项目外,凭营业执照依法自主开展经营活动)","establishingDate": "2022-09-13","legalName": "李欢","registrationCode": "","opFrom": "","creditCode": "91330110MABYJ76842","opPeriod": "","enterpriseName": "杭州数勋科技有限公司","isCopy": 1}}
}
(2)错误返回:
{"code": "1","msg": "参数错误","isFee": 0,"seqNo": null,"data": null
}