几乎大多数得平台项目,都会用得到银行卡认证,身份证认证等等一系列得接口,今天就来弄一下银行卡认证.
打开网址
https://market.aliyun.com/products/57000002/cmapi028281.html?spm=5176.10695662.1996646101.searchclickresult.1d816d38uW15nk
去购买一个免费得认证条数,来免费测试一波!

购买完毕打开网址
https://market.console.aliyun.com/imageconsole/index.htm?#/bizlist?_k=x47vpw

会发现已经购买成功,然后存在了AppKey,AppSecret,AppCode等三个数据,这三个数据是用来做认证得,调用相应得接口,放入相应得数据
寻找依赖
https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml

拉取这四个,最后那个是单元测试得依赖,idea创建maven项目自带junit依赖!

<dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.15</version></dependency><dependency><groupId>org.apache.httpcomponents</groupId><artifactId>httpclient</artifactId><version>4.2.1</version></dependency><dependency><groupId>org.apache.httpcomponents</groupId><artifactId>httpcore</artifactId><version>4.2.1</version></dependency><dependency><groupId>commons-lang</groupId><artifactId>commons-lang</artifactId><version>2.6</version></dependency><dependency><groupId>org.eclipse.jetty</groupId><artifactId>jetty-util</artifactId><version>9.3.7.v20160115</version></dependency>

导入依赖之后,创建Httputils工具类,这个类是用来发送请求并返回数据的.
package cn.itrip.auth.util;

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);}}
}

依赖导入了,工具类也编写完毕了,这个时候就进行简单得单元测试

@Test
public void aa(){String host = "https://b4bankcard.market.alicloudapi.com";String path = "/bank3RealCheck";String method = "GET";String appcode = "fea6b36cadd940db834b8cb9e13a5566";//AppCodeMap<String, String> headers = new HashMap<String, String>();//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105headers.put("Authorization", "APPCODE " + appcode);Map<String, String> querys = new HashMap<String, String>();querys.put("accountNo", "6217002980106201887");//银行卡号querys.put("idCard", "431023199912210032");//身份证// querys.put("mobile", "15773512263");//电话好吗querys.put("name", "曹澳");//姓名//JDK 1.8示例代码请在这里下载:  http://code.fegine.com/Tools.ziptry {/*** 重要提示如下:* HttpUtils请从* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java* 或者直接下载:* http://code.fegine.com/HttpUtils.zip* 下载** 相应的依赖请参照* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml* 相关jar包(非pom)直接下载:* http://code.fegine.com/aliyun-jar.zip*/HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);//System.out.println(response.toString());如不输出json, 请打开这行代码,打印调试头部状态码。//状态码: 200 正常;400 URL无效;401 appCode错误; 403 次数用完; 500 API网管错误//获取response的bodySystem.out.println(EntityUtils.toString(response.getEntity()));} catch (Exception e) {e.printStackTrace();}
}

输出结果为:
上面这个是不需要手机号验证!输出结果测试即可.主要是更改path得提交地址,和注释手机号
接下来用加上手机号的测试

@Test
public void aa(){String host = "https://b4bankcard.market.alicloudapi.com";String path = "/bank4Check";String method = "GET";String appcode = "fea6b36cadd940db834b8cb9e13a5566";//AppCodeMap<String, String> headers = new HashMap<String, String>();//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105headers.put("Authorization", "APPCODE " + appcode);Map<String, String> querys = new HashMap<String, String>();querys.put("accountNo", "6217002980106201887");//银行卡号querys.put("idCard", "431023199912210032");//身份证querys.put("mobile", "15773512263");//电话好吗querys.put("name", "曹澳");//姓名//JDK 1.8示例代码请在这里下载:  http://code.fegine.com/Tools.ziptry {/*** 重要提示如下:* HttpUtils请从* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java* 或者直接下载:* http://code.fegine.com/HttpUtils.zip* 下载** 相应的依赖请参照* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml* 相关jar包(非pom)直接下载:* http://code.fegine.com/aliyun-jar.zip*/HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);//System.out.println(response.toString());如不输出json, 请打开这行代码,打印调试头部状态码。//状态码: 200 正常;400 URL无效;401 appCode错误; 403 次数用完; 500 API网管错误//获取response的bodySystem.out.println(EntityUtils.toString(response.getEntity()));} catch (Exception e) {e.printStackTrace();}
}

输出结果为:

{"status":"01","msg":"验证通过","idCard":"431023199912210032","accountNo":"6217002980106201887","bank":"中国建设银行","cardName":"龙卡通","cardType":"借记卡","name":"曹澳","mobile":"15773512263","sex":"男","area":"湖南省郴州市永兴县","province":"湖南省","city":"郴州市","prefecture":"永兴县","birthday":"1999-12-21","addrCode":"431023","lastCode":"2"}

报错状态码:
https://help.aliyun.com/document_detail/43906.html,(X-Ca-Error-Message字段为错误码字段)在这网址当中会出现,

P2P银行卡绑定(银行卡四要素)相关推荐

  1. android 银行卡绑定银行卡,一种基于Android、iOS系统的移动端银行卡识别方法,让银行卡绑定这一行为变得更轻松...

    迅猛发展的移动互联网产业,类似手机支付宝的移动商业应用琳琅满目,网络购物.理财.商旅应用.打车软件等的兴起,让用户的习惯开始慢慢倾斜,移动支付的场景也愈加丰富起来,给人们带来了丰富多彩且方便快捷的数字 ...

  2. 微信为什么要绑定银行卡?

    微信一定要绑定银行卡吗?如果你不知道其中的原理,那么你就吃大亏了. 很多人对微信绑定银行卡呈现一种无所谓的态度,殊不知微信绑定银行卡的好处很多. 下面我从五个方面来回答这个问题问得有不完善之处还请大家 ...

  3. 支付宝「银行卡绑定流程」设计资源分享

    对于涉及电子商务交易的平台,支付系统的重要性是不言而喻的. 支付系统中一个最重要的环节是绑定银行卡,因为银行卡的绑定直接影响后续的支付和现金提取服务. 当用户执行诸如实名认证和支付密码恢复的敏感操作时 ...

  4. 四川多多开店:拼多多商家绑定银行卡怎么绑定

    不少拼多多商家也希望能够做好各项工作,可是却不知道拼多多在绑定银行卡的时候,是否有时刻约束,另外假如不想要操作了,也能够挑选解绑,下面就来给各位介绍相关的流程. 拼多多绑定银行卡没有时刻约束,假如各位 ...

  5. android银行卡绑定,华为huawei pay怎么绑定银行卡 绑卡方法教程

    华为huawei pay怎么绑定银行卡 绑卡方法教程 来源:www.18183.com作者:皮卡时间:2016-03-10 华为pay怎么绑定银行卡?可能还有用户还不会在华为pay上绑定银行卡,下文给 ...

  6. vant 绑定银行卡页面+验证所属银行+身份证号码+所属银行选择器

    <template><div><van-nav-bar class="navBar" style="background-color: wh ...

  7. php如何实现余额充值,请问应用中实现绑定银行卡并进行消费、充值、提现一般是怎么搞的?...

    我现在的系统中要实现一个个人账户,因此希望能够满足充值.提现.消费等业务,不知道怎么搞法比较好,是不是要和第三方金融支付平台合作的.我看了下,还有像饿了么这种APP,不绑定银行卡,充值的时候就支持微信 ...

  8. 微信小程序绑定银行卡

    最近在做一个项目,其中有绑定银行卡的需求,所以写下来分享给用得到各位小伙伴 代码如下: WXML: <view class="bind-card-box"><vi ...

  9. apple pay支持的银行有哪些?如何绑定银行卡?

    apple pay支持的银行有哪些?如何绑定银行卡? 2月15日的一条新闻可谓火遍了整个科技圈,2月18日苹果Apple Pay将正式登陆中国大陆;2015年12月18日,苹果Apple Pay就宣布 ...

  10. PHP【连连支付】查询用户绑定银行卡

    应用场景: 在个人中心,查看个人绑卡列表,获取用户使用连连支付绑定的银行卡列表. 实现: // 用户绑定银行卡查询public function getMyCardList(){$user = $th ...

最新文章

  1. Java深入了解String对象
  2. Java 8系列之Stream中万能的reduce
  3. 深刻好文|关于资产与负债的思考(国庆活动开启)
  4. [MyBatisPlus]通用枚举
  5. P2678 [NOIP2015 提高组] 跳石头
  6. requests库之处理响应
  7. 【激活函数】PRelu激活函数
  8. 剑指offer(面试战备ing,持续更新)
  9. 如何在 Mac 上快速输入 Apple 图标?
  10. ppt矩形里面的图片怎么放大缩小_PPT图片局部放大技巧
  11. 科立捷默认频率_科立捷(KOLEEJ) 【京东配送·隔日达】民用大功率自驾游酒店地下室隧道4S店对讲机 KLJ-T10...
  12. Dorado7常用JS以及常见错误
  13. 戴尔服务器怎么win7系统安装系统,戴尔 DELLVostro3400能不能安装windows7系统_戴尔 DELLVostro3400怎么安装win7系统-win7之家...
  14. 计算机网络技术实训 实训总结,计算机网络技术实训报告总结.docx
  15. 26 | 产品安全方案:如何降低业务对黑灰产的诱惑?
  16. PHP中 字符串 常用函数
  17. Python 豆瓣网的全自动登录(豆瓣验证码自动识别)
  18. 利用华硕路由器实现创维电视广告屏蔽
  19. 在linux服务器上用headless firefox打开中文网页,字体乱码问题
  20. 银行ATM登录管理系统(最简版)

热门文章

  1. 恒讯科技分享:rust服务器搭建教程
  2. 数据分析几大常见效应和定律。
  3. 数据备份与数据容灾全解析
  4. Bailian2967 特殊日历计算【日期计算】
  5. MYSQL将两张表的数据合并显示
  6. mysql hive的导数_记一次蛋疼的mongo to hive导数过程
  7. 三角函数和差公式的推导
  8. 慕课网-前端课程学习完成
  9. python def是什么意思-python里面def是什么意思
  10. python3 使用sorted 实现倒序