/** * 实名认证 * * @param userId * @param certNo * @param authType * @return * Created by yy.uptonn on 2017-9-30. */ public boolean certification_authentication(int userId, String certNo, String authType) { UserEntity entity = userService.findUserById(userId); Map headers = new HashMap(); //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105 headers.put("Authorization", "APPCODE " + AppCode); //根据API的要求,定义相对应的Content-Type headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); Map querys = new HashMap(); Map bodys = new HashMap(); bodys.put("bizNo", "ZM201612013000000242400404124269"); bodys.put("name", entity.getName()); bodys.put("certNo", certNo); bodys.put("certType", "IDENTITY_CARD"); try { /** * 相应的依赖请参照 * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml */ HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys); String return_obj = EntityUtils.toString(response.getEntity()); JSONObject object = JSON.parseObject(return_obj); if(object.getString("success").equals("true")) { return true; } //获取response的body //System.out.println(EntityUtils.toString(response.getEntity())); } catch (Exception e) { e.printStackTrace(); } return false; }