如今随着互联网产业的多元化发展,尤其是互联网金融,O2O,共享经济等新兴商业形式的兴起,企业对实名认证业务的数据形式和数据质量有了更高的需求。如今也衍生出银行卡实名认证业务,通过接口将【银行卡号、身份证号码、姓名】或者【银行卡号、身份证号码、姓名、手机号】上传至阿里云,再与银行系统进行匹配,判断信息的一致性。

首先点击:【 阿里云API接口服务】获取相应的订单后在控制台中可以得到您的appcode;

具体实现类(java):

public static void main(String[] args) {String host = "https://yunyidata3.market.alicloudapi.com";String path = "/bankAuthenticate3";String method = "POST";String appcode = "你自己的AppCode";Map<String, String> headers = new HashMap<String, String>();//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105headers.put("Authorization", "APPCODE " + appcode);//根据API的要求,定义相对应的Content-Typeheaders.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");Map<String, String> querys = new HashMap<String, String>();Map<String, String> bodys = new HashMap<String, String>();bodys.put("cardNo", "62155811111111111");bodys.put("idNo", "340421199922225555");bodys.put("name", "张三");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());//获取response的body//System.out.println(EntityUtils.toString(response.getEntity()));} catch (Exception e) {e.printStackTrace();}}

工具类HttpUtils:

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;public class HttpUtils {/*** get* * @param host* @param path* @param method* @param headers* @param querys* @return* @throws Exception*/public static HttpResponse doGet(String host, String path, String method, Map<String, String> headers, Map<String, String> querys)throws Exception {        HttpClient httpClient = wrapClient(host);HttpGet request = new HttpGet(buildUrl(host, path, querys));for (Map.Entry<String, String> e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}return httpClient.execute(request);}/*** post form* * @param host* @param path* @param method* @param headers* @param querys* @param bodys* @return* @throws Exception*/public static HttpResponse doPost(String host, String path, String method, Map<String, String> headers, Map<String, String> querys, Map<String, String> bodys)throws Exception {        HttpClient httpClient = wrapClient(host);HttpPost request = new HttpPost(buildUrl(host, path, querys));for (Map.Entry<String, String> e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}if (bodys != null) {List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();for (String key : bodys.keySet()) {nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));}UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");request.setEntity(formEntity);}return httpClient.execute(request);}    /*** Post String* * @param host* @param path* @param method* @param headers* @param querys* @param body* @return* @throws Exception*/public static HttpResponse doPost(String host, String path, String method, Map<String, String> headers, Map<String, String> querys, String body)throws Exception {        HttpClient httpClient = wrapClient(host);HttpPost request = new HttpPost(buildUrl(host, path, querys));for (Map.Entry<String, String> e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}if (StringUtils.isNotBlank(body)) {request.setEntity(new StringEntity(body, "utf-8"));}return httpClient.execute(request);}/*** Post stream* * @param host* @param path* @param method* @param headers* @param querys* @param body* @return* @throws Exception*/public static HttpResponse doPost(String host, String path, String method, Map<String, String> headers, Map<String, String> querys, byte[] body)throws Exception {        HttpClient httpClient = wrapClient(host);HttpPost request = new HttpPost(buildUrl(host, path, querys));for (Map.Entry<String, String> e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}if (body != null) {request.setEntity(new ByteArrayEntity(body));}return httpClient.execute(request);}/*** Put String* @param host* @param path* @param method* @param headers* @param querys* @param body* @return* @throws Exception*/public static HttpResponse doPut(String host, String path, String method, Map<String, String> headers, Map<String, String> querys, String body)throws Exception {        HttpClient httpClient = wrapClient(host);HttpPut request = new HttpPut(buildUrl(host, path, querys));for (Map.Entry<String, String> e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}if (StringUtils.isNotBlank(body)) {request.setEntity(new StringEntity(body, "utf-8"));}return httpClient.execute(request);}/*** Put stream* @param host* @param path* @param method* @param headers* @param querys* @param body* @return* @throws Exception*/public static HttpResponse doPut(String host, String path, String method, Map<String, String> headers, Map<String, String> querys, byte[] body)throws Exception {        HttpClient httpClient = wrapClient(host);HttpPut request = new HttpPut(buildUrl(host, path, querys));for (Map.Entry<String, String> e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}if (body != null) {request.setEntity(new ByteArrayEntity(body));}return httpClient.execute(request);}/*** Delete*  * @param host* @param path* @param method* @param headers* @param querys* @return* @throws Exception*/public static HttpResponse doDelete(String host, String path, String method, Map<String, String> headers, Map<String, String> querys)throws Exception {        HttpClient httpClient = wrapClient(host);HttpDelete request = new HttpDelete(buildUrl(host, path, querys));for (Map.Entry<String, String> e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}return httpClient.execute(request);}private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {StringBuilder sbUrl = new StringBuilder();sbUrl.append(host);if (!StringUtils.isBlank(path)) {sbUrl.append(path);}if (null != querys) {StringBuilder sbQuery = new StringBuilder();for (Map.Entry<String, String> query : querys.entrySet()) {if (0 < sbQuery.length()) {sbQuery.append("&");}if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {sbQuery.append(query.getValue());}if (!StringUtils.isBlank(query.getKey())) {sbQuery.append(query.getKey());if (!StringUtils.isBlank(query.getValue())) {sbQuery.append("=");sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));}                    }}if (0 < sbQuery.length()) {sbUrl.append("?").append(sbQuery);}}return sbUrl.toString();}private static HttpClient wrapClient(String host) {HttpClient httpClient = new DefaultHttpClient();if (host.startsWith("https://")) {sslClient(httpClient);}return httpClient;}private static void sslClient(HttpClient httpClient) {try {SSLContext ctx = SSLContext.getInstance("TLS");X509TrustManager tm = new X509TrustManager() {public X509Certificate[] getAcceptedIssuers() {return null;}public void checkClientTrusted(X509Certificate[] xcs, String str) {}public void checkServerTrusted(X509Certificate[] xcs, String str) {}};ctx.init(null, new TrustManager[] { tm }, null);SSLSocketFactory ssf = new SSLSocketFactory(ctx);ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);ClientConnectionManager ccm = httpClient.getConnectionManager();SchemeRegistry registry = ccm.getSchemeRegistry();registry.register(new Scheme("https", 443, ssf));} catch (KeyManagementException ex) {throw new RuntimeException(ex);} catch (NoSuchAlgorithmException ex) {throw new RuntimeException(ex);}}
}

希望大家搬砖快乐,有问题可留言共同讨论!

使用阿里云接口进行银行卡三四要素实名认证(阿里云api接口java)相关推荐

  1. 使用阿里云接口进行银行卡三要素实名认证

    如今随着互联网产业的多元化发展,尤其是互联网金融,O2O,共享经济等新兴商业形式的兴起,企业对实名认证业务的数据形式和数据质量有了更高的需求.如今也衍生出银行卡实名认证业务,通过接口将[银行卡号.身份 ...

  2. java获取api接口新浪数据,新浪短网址API接口的获取以及API接口的调用文档分享...

    我们可能会收到类似于这样的短信,发现其中的链接并不是常规的网址链接,而是个短小精悍的短链接,产品中经常需要这样的需求,如果在给用户下发的短信中是一个很长的连接,用户体验肯定很差,因此我们需要实现长链接 ...

  3. 京东整店商品查询API接口(item_search_shop-获得店铺的所有商品API接口)

    可以通过京东整店商品列表接口采集店铺所有商品详情页各项数据,包含商品标题,skuid.价格.优惠价,收藏数.月销售量.SKU图.标题.详情页图片等页面上有的数据均可以拿到,大家都知道,京东的反爬虫机制 ...

  4. 最新最全的免费股票数据接口--沪深A股基础列表数据API接口(三)

    沪深A股基础实时数据API 数据来源:麦蕊智数 请求方式:Get(直接在浏览器打开就可以看到返回的数据) 数据格式:标准Json格式[{},...{}] 数据时效:实时更新 API说明文档:https ...

  5. 淘宝商品评价api接口(item_review-获得淘宝商品评论API接口),天猫商品评论API接口

    淘宝商品评价api接口(item_review-获得淘宝商品评论API接口),天猫商品评论API接口可通过商品id,获取商品评价信息.评价内容.买家秀图片.评论浏览量.评价视频.评价追评等页面上的数据 ...

  6. 京东店铺的所有商品API接口(item_search_shop-获得店铺的所有商品API接口),整店商品API接口

    可以通过京东店铺的所有商品API接口采集店铺所有商品详情页各项数据,包含商品标题,SKU信息.价格.优惠价,收藏数.销量.SKU图.标题.详情页图片等页面上有的数据均可以拿到,大家都知道,京东的反爬虫 ...

  7. 如果实现银行卡三四要素? 银行卡实名认证

    银行卡四要素-银行卡实名认证-银行卡四要素认证-银行卡四要素核验-银行卡四要素实名 -银行卡四要素查询-银行卡认证[北斗数聚][最新版]_银行卡二元素认证_银行卡三元素认证_银行卡四元素认证-云市场- ...

  8. tp5.1 乐视云上传视频文件(https请求http乐视云上传接口)http网址下上传视频(https API接口)

    一.sdk_php_v2.0.zip 上传视频 网址:http://www.lecloud.com/zh-cn/help/api.html tp5.1 乐视云上传视频文件(https请求http乐视云 ...

  9. wcf afterreceiverequest获取body数据_阿里面试官的灵魂拷问:究竟如何保证API接口数据安全?...

    前言 前后端分离的开发方式,我们以接口为标准来进行推动,定义好接口,各自开发自己的功能,最后进行联调整合.无论是开发原生的APP还是webapp还是PC端的软件,只要是前后端分离的模式,就避免不了调用 ...

  10. python后端接口怎么写_看看人家那后端API接口写得,那叫一个优雅!

    程序员的成长之路 互联网/程序员/技术/资料共享 阅读本文大概需要 4 分钟. 来自:今日头条,作者:老顾聊技术 链接:https://www.toutiao.com/i669440464582711 ...

最新文章

  1. 在IE7中无效的解决办法
  2. Gartner预测:2019年七大AI科技趋势,百万行业将颠覆!
  3. 深入分析 Java 中的中文编码问题--转
  4. Create React App 2.0 华丽登场
  5. final 最终 java 1614876717
  6. 制作win10安装u盘_最简单的Win10系统安装U盘制作方法
  7. java线程三种创建方式与线程池的应用
  8. Spring Cloud 微服务的那点事
  9. Shell脚本编程之(二)简单的Shell脚本练习
  10. WPF 获取控件模板中的控件
  11. 【bzoj1093】[ZJOI2007]最大半连通子图 Tarjan+拓扑排序+dp
  12. 将DLL注册成COM组件
  13. python:实现Diffie-Hellman算法(附完整源码)
  14. 2011计算机一级a,2011河北省大学生计算机一级A卷操作步骤
  15. 【每日一练】21—CSS实现炫酷动画背景
  16. 我用 PyTorch 复现了 LeNet-5 神经网络(MNIST 手写数据集篇)!
  17. uniapp上高德(百度)地图API的使用(APP安卓)
  18. 评估期已过。有关如何升级您的测试版软件的信息 请访问
  19. 安装Docker,在本机上跑一个‘2048’小游戏(脉冲云在线体验)
  20. 如何使用Spring Boot促进java开发?高级java架构师为您详解!

热门文章

  1. Docker-基本命令和漏洞分享
  2. RESTFUL API 安全设计指南
  3. 动态IP和静态IP地址
  4. c51单片机时钟程序汇编语言,51单片机时钟汇编程序
  5. ps 批处理图片大小和压缩
  6. docker 启动 redis cluster,使用出现CLUSTERDOWN Hash slot not served(redis cluster重新分配slot)
  7. 三极管之——PNP与NPN
  8. uni-app的checkbox多选和全选
  9. 十二个“一”---十二位胜似亲人的悲情向团体详解
  10. python3内建排序函数:sorted()详解