puzhibing
2023-02-15 2811bab657aab4145b65a45a824fb63e93b58e30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.stylefeng.guns.modular.system.util;
 
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.HashMap;
import java.util.Map;
 
/**
 * 阿里云API接口工具类
 */
@Component
public class ALiApiUtil {
 
    @Autowired
    private HttpClientUtil httpClientUtil;
 
 
    /**
     * 身份认证接口
     * @param name  姓名
     * @param code  身份证号
     * @return
     */
    public boolean authentication(String name, String code){
        String url = "https://safrvcert.market.alicloudapi.com/safrv_2meta_id_name/";
        Map<String, String> header = new HashMap<>();
        header.put("Authorization", "APPCODE b7d32437d08149099457dcb50fb57df2");
        Map<String, Object> param = new HashMap<>();
        param.put("__userId", "1732960796168165");
        param.put("verifyKey", "IVO4js5kValcdt");
        param.put("userName", name);
        param.put("identifyNum", code);
        String get = httpClientUtil.pushHttpRequset("GET", url, param, header, "form");
        JSONObject jsonObject = JSON.parseObject(get);
        if(jsonObject.getIntValue("code") == 200){
            JSONObject value = jsonObject.getJSONObject("value");
            if(value.getString("bizCode").equals("0")){
                return true;
            }else{
                return false;
            }
        }else{
            System.err.println(jsonObject.getString("message"));
        }
        return false;
    }
}