|
@@ -23,6 +23,14 @@ public class FacePlusApiHelper {
|
|
private final static Logger log = LoggerFactory.getLogger(FacePlusApiHelper.class);
|
|
private final static Logger log = LoggerFactory.getLogger(FacePlusApiHelper.class);
|
|
|
|
|
|
public static FaceResult faceDetect(FaceVerifyProperties properties, Map<String, String> params) {
|
|
public static FaceResult faceDetect(FaceVerifyProperties properties, Map<String, String> params) {
|
|
|
|
+ if (StringUtils.isBlank(properties.getFacePlusKey())) {
|
|
|
|
+ throw new IllegalArgumentException("[FACE++] apiKey must be not empty.");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isBlank(properties.getFacePlusSecret())) {
|
|
|
|
+ throw new IllegalArgumentException("[FACE++] apiSecret must be not empty.");
|
|
|
|
+ }
|
|
|
|
+
|
|
FormBody.Builder formBody = new FormBody.Builder();
|
|
FormBody.Builder formBody = new FormBody.Builder();
|
|
formBody.add("api_key", properties.getFacePlusKey());
|
|
formBody.add("api_key", properties.getFacePlusKey());
|
|
formBody.add("api_secret", properties.getFacePlusSecret());
|
|
formBody.add("api_secret", properties.getFacePlusSecret());
|
|
@@ -77,6 +85,14 @@ public class FacePlusApiHelper {
|
|
}
|
|
}
|
|
|
|
|
|
public static FaceResult faceCompare(FaceVerifyProperties properties, Map<String, String> params) {
|
|
public static FaceResult faceCompare(FaceVerifyProperties properties, Map<String, String> params) {
|
|
|
|
+ if (StringUtils.isBlank(properties.getFacePlusKey())) {
|
|
|
|
+ throw new IllegalArgumentException("[FACE++] apiKey must be not empty.");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isBlank(properties.getFacePlusSecret())) {
|
|
|
|
+ throw new IllegalArgumentException("[FACE++] apiSecret must be not empty.");
|
|
|
|
+ }
|
|
|
|
+
|
|
FormBody.Builder formBody = new FormBody.Builder();
|
|
FormBody.Builder formBody = new FormBody.Builder();
|
|
formBody.add("api_key", properties.getFacePlusKey());
|
|
formBody.add("api_key", properties.getFacePlusKey());
|
|
formBody.add("api_secret", properties.getFacePlusSecret());
|
|
formBody.add("api_secret", properties.getFacePlusSecret());
|
|
@@ -156,7 +172,7 @@ public class FacePlusApiHelper {
|
|
}
|
|
}
|
|
|
|
|
|
if (code == 413) {
|
|
if (code == 413) {
|
|
- // 客户发送的请求大小超过了2MB限制。该错误的返回格式为纯文本,不是json格式。
|
|
|
|
|
|
+ // 请求大小超过了2MB限制。该错误的返回格式为纯文本,不是json格式。
|
|
FacePlusResponse result = new FacePlusResponse();
|
|
FacePlusResponse result = new FacePlusResponse();
|
|
result.setError_message("IMAGE_FILE_TOO_LARGE");
|
|
result.setError_message("IMAGE_FILE_TOO_LARGE");
|
|
return result;
|
|
return result;
|