import com.chinaums.open.api.OpenApiCache;
import com.chinaums.open.api.OpenApiContext;
import com.chinaums.open.api.constants.ConfigBean;
import com.chinaums.open.api.internal.util.http.HttpTransport;
import java.util.UUID;
public class OpenApiSdkTest {
public static void main(String[] args) throws Exception{
String url = "/v1/datacenter/smartverification/encrypted/idcard/verify";
//开发者ID
String appId = "平台分配";
//开发者秘钥
String appKey = "平台分配";
//实例化客户端
ConfigBean configBean = new ConfigBean();
OpenApiContext context = new OpenApiContext();
String request = "{\"data\":\"\"}";
context.setStartTime(System.currentTimeMillis());
context.setRequestId(UUID.randomUUID().toString().replace("-", ""));
context.setOpenServUrl(url.split("/v")[0].concat("/"));
context.setApiServiceUrl(url);
context.setVersion(url.split("/")[3]);
context.setAppId(appId);
context.setAppKey(appKey);
context.setConfigBean(configBean);
context.setServiceCode(url.split("/v")[1].substring(1));
OpenApiCache.getCurrentToken(context);
System.out.println(HttpTransport.getInstance().doPost(context, request));
}
}
<?php
require_once "../utils/Log.php";
require_once "../utils/Tools.php";
require_once "../DefaultOpenApiClient.php";
class DataRequest
{
public $url = "";
public $serviceCode = "";
public $apiVersion ="";
public $needToken = true;
public $needDataTag = false;
public $data;
function __construct($data, $url)
{
$this->data = $data;
$apiVersion = preg_split("/[/]+/s",$url)[2];
$this->apiVersion = $apiVersion;
$serviceCode = strstr($url,$apiVersion);
$this->url = strstr($url,"/".$apiVersion,true);
$this->serviceCode = preg_replace("/^" . preg_quote($apiVersion, "/") . "/", "", $serviceCode);
}
}
class DataDemo{
public function main(){
$appid = "平台分配";
$appkey = "平台分配";
$url = "/v1/datacenter/smartverification/encrypted/idcard/verify";
$data = json_encode(array("data"=>""));
$reqiest = new DataRequest($data,$url);
$client = new DefaultOpenApiClient();
$content = $client->execute($reqiest,$appid,$appkey);
$obj = json_decode($content);
print_r($obj->errCode);
print_r($obj->errInfo);
}
}
$p = new DataDemo();
$p->main();
?>
# -*- coding: utf-8 -*-
from webapi.DefaultOpenApiClient import DefaultOpenApiClient
url = "/v1/datacenter/smartverification/encrypted/idcard/verify"
class DataRequest(object):
def __init__(self, data: dict) -> dict:
self.data = data
self.serviceCode = url[len(url.split("/v")[0])+len(url.split("/")[3])+1: len(url)]
self.apiVersion = url.split("/")[3]
self.needToken = True
self.needDataTag = True
appId="平台分配"
appKey="平台分配"
client = DefaultOpenApiClient(appId, appKey)
cls = DataRequest({\"data\":\"\"})
response = client.execute(cls)
print(str(response.get("data")))
print(response.get("errCode"))
print(response.get("errInfo"))
print(response.get("resultCode"))
print(response.get("resultInfo"))
身份证信息核验接口
URL
- 生产环境:
POST
https://api-mop.chinaums.com/v1/datacenter/smartverification/encrypted/idcard/verify
描述:
ContentType:HTTP(S) + JSON
请求头
名称 | 必填 | 描述 | 示例值 |
---|---|---|---|
Authorization | 是 | 认证内容 | |
Content-Type | 是 | application/json;charset=utf-8 |
请求参数
名称 | 类型 | 必填 | 最大长度 | 描述 | 示例值 |
---|---|---|---|---|---|
data | stringObject | 是 | 对下面转换的Json字符串用SM2公钥进行加密,然后对加密后的报文用base64编码 | ||
keyType | string | 是 | - | 查询关键字类型。取值2。 | 2:身份证实名验证 |
certNo | string | 是 | - | 身份证号码 | |
name | string | 是 | - | 用户姓名 | |
userNo | string | 否 | - | 用户号 |
响应示例
{
"errCode":"",
"errInfo":"",
"data":"",
"resultCode":"",
"resultInfo":""
}
响应参数
名称 | 类型 | 必填 | 最大长度 | 描述 | 示例值 |
---|---|---|---|---|---|
errCode | string | 是 | - | 错误代码 详见错误码说明 | |
errInfo | string | 是 | - | 错误说明 | |
data | stringObject | 是 | 对返回加密报文用base64解码后,用SM2对应的私钥解密 | ||
resultCode | string | 是 | 64 | 第三方返回错误代码 | |
resultInfo | string | 是 | 64 | 第三方返回错误信息 |
错误码
错误码 | 错误描述 | 解决方案 |
---|---|---|
00 | 认证成功 | 应答码 |
01 | 认证失败 | 应答码 |
02 | 库中无此号 | 应答码 |
03 | 查询要素格式有误 | 应答码 |
04 | 系统异常 | 应答码 |
05 | 超出权限 | 应答码 |