基于HUAWEI AppGallery Connect开发了一款App,我得出了这几点结论!
腾讯员工平均年薪近百万,工程师一个月赚8万!网友:我和马云财产加起来过千亿,我骄傲了嘛?
华科女博士年薪156万入职华为!最新回应:在深圳也难买房…计算机技能需求最新排名:Python 仅排第 3,第 1 你肯定猜不到
点击“开发者技术前线”,选择“星标”
在看|星标|留言, 真爱
/**
* @param imageUrl
* @return pass-放行, forbid-封禁, check-人工审核
* @throws Exception
*/
public String check(String imageUrl) {
String ucloudUrl = "http://api.uai.ucloud.cn/v1/image/scan";
String appId = "uaicensor-rjmvogpx";
String uaicensorPublicKey = null;
String uaicensorPrivateKey = null;
//图片绝对路径
RestTemplate rest = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
/**
* 生成signature,首字母排序
*/
String timestamp = System.currentTimeMillis() + "";
SortedMap<Object, Object> packageParams = new TreeMap<>();
packageParams.put("PublicKey", uaicensorPublicKey);
packageParams.put("ResourceId", appId);
packageParams.put("Timestamp", timestamp);
packageParams.put("Url", imageUrl);
String signature = null;
try {
signature = UCloudUtil.createSign(packageParams, uaicensorPrivateKey);
} catch (Exception e) {
return null;
}
/**
* 参数
*/
MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
param.add("Scenes", "porn");
param.add("Method", "url");
param.add("Url", imageUrl);
/**
* headers 参数
*/
headers.setContentType(MediaType.parseMediaType("multipart/form-data; charset=UTF-8"));
headers.set("PublicKey", uaicensorPublicKey);
headers.set("Signature", signature);
headers.set("ResourceId", appId);
headers.set("Timestamp", timestamp);
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<>(param, headers);
ResponseEntity<String> responseEntity = rest.exchange(ucloudUrl, HttpMethod.POST, httpEntity, String.class);
String body = responseEntity.getBody();
JSONObject jsonObject = JSON.parseObject(body);
if (jsonObject.getInteger("RetCode") == 0) {
String res = jsonObject.getJSONObject("Result").getJSONObject("Porn").getString("Suggestion");
return res;
}
return null;
}
扫码进群,你奖获得:
大厂内推和技术交流,前沿学术交流