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/gate/identify-face";
//开发者ID
String appId = "平台分配";
//开发者秘钥
String appKey = "平台分配";
//实例化客户端
ConfigBean configBean = new ConfigBean();
OpenApiContext context = new OpenApiContext();
String request = "{\"requestBody\":\"{\"msgHead\":\"{\"orgSendTransID\":\"\",\"deviceId\":\"\",\"reserve\":\"\"}\",\"msgBody\":\"{\"imgString\":\"\"}\"}\"}";
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/gate/identify-face";
$data = json_encode(array("requestBody"=>"{"msgHead"=>"{"orgSendTransID"=>"","deviceId"=>"","reserve"=>""}","msgBody"=>"{"imgString"=>""}"}"));
$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/gate/identify-face"
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({\"requestBody\":\"{\"msgHead\":\"{\"orgSendTransID\":\"\",\"deviceId\":\"\",\"reserve\":\"\"}\",\"msgBody\":\"{\"imgString\":\"\"}\"}\"})
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/gate/identify-face
描述:该接口用于闸机端人脸识别
ContentType:application/json
请求头
名称 | 必填 | 描述 | 示例值 |
---|---|---|---|
Authorization | 是 | 认证内容 请见认证流程章节 |
请求参数
名称 | 类型 | 必填 | 最大长度 | 描述 | 示例值 |
---|---|---|---|---|---|
requestBody | object | 是 | 宇泛对接人脸识别接口请求报文体,格式为{"msgHead":{……},"msgBody":{……}} | ||
msgHead | object | 是 | |||
orgSendTransID | string | 是 | 64 | 请求流水号 | |
deviceId | string | 是 | 64 | 设备号 | |
reserve | string | 否 | 64 | 保留域 | |
msgBody | object | 是 | |||
imgString | string | 是 | 64 | 照片的base64编码字符串 图像数据base64编码,编码后大小不超过5MB图片为JPG/JPEG/BMP/PNG格式 |
响应示例
{
"errCode":"",
"errInfo":"",
"result":
{
"msgHead":
{
"orgSendTransId":"请求流水号",
"orgRcvTransID":"",
"deviceId":"",
"errCode":"",
"errInfo":"",
"reserve":""
},
"msgBody":
{
"faceID":"",
"personName":"",
"personID":"",
"location":"",
"sore":0
}
}
}
响应参数
名称 | 类型 | 必填 | 最大长度 | 描述 | 示例值 |
---|---|---|---|---|---|
errCode | string | 是 | 64 | 应答码 0000为成功,其他为失败 | |
errInfo | string | 是 | 64 | 应答信息 | |
result | object | 是 | |||
msgHead | object | 是 | |||
orgSendTransId | string | 是 | 64 | 请求流水号 | |
orgRcvTransID | string | 是 | 64 | 接受流水号 | |
deviceId | string | 是 | 64 | 设备号 | |
errCode | string | 是 | 64 | 返回码 errCode非0000时,msgBody为空 | |
errInfo | string | 是 | 64 | 返回码说明 人脸采集设备或者闸机设备号 | |
reserve | string | 是 | 64 | 保留域 | |
msgBody | object | 是 | |||
faceID | string | 是 | 64 | 人脸唯一标识 | |
personName | string | 是 | 64 | 人员名称 | |
personID | string | 是 | 64 | 人员编号 | |
location | string | 是 | 64 | 人脸位置 | |
sore | number | 是 | 64 | 得分 |