BankCardOcrApp.java 2.27 KB
package com.webank.pass;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.webank.one.GetSIGNTicketTest;
import com.webank.one.access_token;
import com.webank.utils.*;

import net.sf.json.JSONObject;

/**
 * 
 * [ 身份证 R OCR 识别 ]
 * [功能详细描述]
 * 	
 * @author  fwq 
 * @version  [v1.0, 2017年11月7日]
 * @see  [相关类/方法]
 * @since  [产品/模块版本]
 */
public class BankCardOcrApp {

	final static  String appid = "";
	final static  String secret = "";
	final static 	String version = "1.0.0";
	final static 	String orderNo = "1234567890123456789012345678900a";

	public static void main(String[] args) throws Exception{

		String tokne= access_token.getToken(appid,secret);

		String signticket= GetSIGNTicketTest.getSignticket(appid,tokne);


		//方式一  直接传图片路径
			   String imgbese= Img2Base64Util.getImgStr("d:\\zzz.jpg");
			//方式二  传图片url
//			   String base64ByImgUrl = ImageUtils.image2Base64("");
		//设置签名所需要的参数
		List<String> codes = InvertCodeGeneratorUitls.genCodes(32, 1);
		String nonce=codes.get(0);
		ArrayList<String> list = new ArrayList<String>();
		list.add(appid);
		list.add(orderNo);
		list.add(nonce);
		list.add(version);
		
		//获取签名
		System.err.println("第二部执行获取paas请求的"+"sha1加密工具参数      "+list);
		System.out.println();
		String getqianming = QianMingUitls.getqianming(list, signticket);
		System.out.println();
		System.out.println("获取执行paas请求的"+"SingTicket    "+signticket);
		System.out.println();
		System.out.println("获取执行paas请求的"+getqianming.length()+"位签名为       "+getqianming);
		
		final String Url="https://miniprogram-kyc.tencentcloudapi.com/api/paas/bankcardocrapp";
		
		JSONObject params = new JSONObject();
	    
	    params.put("webankAppId", appid);
	    params.put("version", version);
	    params.put("nonce", nonce);
	    params.put("sign", getqianming);
	    params.put("orderNo", orderNo);
	    params.put("cardType", "0");
	    params.put("bankcardStr", imgbese);
	
		HttpClientUtil httpClientUtil = new HttpClientUtil();
        String xmlData = httpClientUtil.doPost(Url, params.toString(), "utf-8");
        System.out.println(xmlData);
        
	}
	 
}