Step By Step
1、API简介
2、Open API Exployer快速测试
3、本地PHP SDK集成
一、API功能简介
- 1.1 功能描述
身份证识别可以识别二代身份证关键字段内容,关键字段包括:姓名、性别、民族、身份证号、出生日期、地址信息、有效起始时间、签发机关,同时可输出身份证区域位置和人脸位置信息。
二、Open API Exployer快速测试
- 测试地址:链接
三、本地PHP SDK集成
- 3.1 SDK安装
composer require alibabacloud/client
- 3.2 Code Sample
<?php
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;
require_once 'vendor\autoload.php';
// access_key_id, access_key_secret 获取参考链接:https://yq.aliyun.com/articles/693979
AlibabaCloud::accessKeyClient('access_key_id','access_key_secret')->asDefaultClient()
->regionId('cn-shanghai')
->asDefaultClient();
try {
$result = AlibabaCloud::rpc()
->product('ocr')
// ->scheme('https') // https | http
->version('2019-12-30')
->action('RecognizeIdentityCard')
->method('POST')
->host('ocr.cn-shanghai.aliyuncs.com')
->options([
'query' => [
'Side' => "face",
'ImageURL' => "https://viapi-oss.oss-cn-shanghai.aliyuncs.com/doc/ocr/shenfz.jpg",
],
])
->request();
print_r($result->toArray());
} catch (ClientException $e) {
echo $e->getErrorMessage() . PHP_EOL;
} catch (ServerException $e) {
echo $e->getErrorMessage() . PHP_EOL;
}
- 3.3 测试结果