|
@@ -172,4 +172,45 @@ public class EntityAnalyse {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+ public static DistinguishView licenseShibie(String licenseImg) throws ServiceException {
|
|
|
+
|
|
|
+ String host = "https://bizlicense.market.alicloudapi.com";
|
|
|
+ String path = "/rest/160601/ocr/ocr_business_license.json";
|
|
|
+ String method = "POST";
|
|
|
+ String appcode = "2d59bfa794994f5f94d1d98b7b5bd102";
|
|
|
+ Map<String, String> headers = new HashMap<String, String>();
|
|
|
+ //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
|
|
|
+ headers.put("Authorization", "APPCODE " + appcode);
|
|
|
+ //根据API的要求,定义相对应的Content-Type
|
|
|
+ headers.put("Content-Type", "application/json; charset=UTF-8");
|
|
|
+ Map<String, String> querys = new HashMap<String, String>();
|
|
|
+ String bodys = "{\"image\":\""+licenseImg+"\"}";
|
|
|
+ //阿里云APPCODE
|
|
|
+ DistinguishView distinguishView = new DistinguishView();
|
|
|
+ try {
|
|
|
+ /**
|
|
|
+ * 重要提示如下:
|
|
|
+ * HttpUtils请从
|
|
|
+ * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
|
|
|
+ * 下载
|
|
|
+ *
|
|
|
+ * 相应的依赖请参照
|
|
|
+ * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
|
|
|
+ */
|
|
|
+ HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
|
|
|
+ System.out.println(response.toString());
|
|
|
+ String body = EntityUtils.toString(response.getEntity());
|
|
|
+ System.out.println(body);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(body);
|
|
|
+ distinguishView.setRegNum(jsonObject.getString("reg_num"));
|
|
|
+ distinguishView.setValidPeriod(jsonObject.getString("valid_period"));
|
|
|
+ distinguishView.setLicenseName(jsonObject.getString("name"));
|
|
|
+ distinguishView.setLicensePerson(jsonObject.getString("person"));
|
|
|
+ return distinguishView;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|