import com.baidubce.http.ApiExplorerClient; import com.baidubce.http.AppSigner; import com.baidubce.http.HttpMethodName; import com.baidubce.model.ApiExplorerRequest; import com.baidubce.model.ApiExplorerResponse; // 银行卡OCR识别 Java示例代码 public class RequestDemo { public static void main(String[] args) { String path = "http://gwgp-ccmacsvevbu.n.bdcloudapi.com/bankcard/ocr"; ApiExplorerRequest request = new ApiExplorerRequest(HttpMethodName.POST, path); request.setCredentials("您的 access key", "您的 secret key"); request.addHeaderParameter("Content-Type", "application/x-www-form-urlencoded"); ApiExplorerClient client = new ApiExplorerClient(new AppSigner()); try { ApiExplorerResponse response = client.sendRequest(request); // 返回结果格式为Json字符串 System.out.println(response.getResult()); } catch (Exception e) { e.printStackTrace(); } } }
点击复制代码
{
"msg": "",
"success": true,
"code": 200,//200时计费
"data":{
"order_no": "57462827766736****",
"exif_orientation": null,
"image_id": "8cb18aecc9bf4c8683f2c2d13119****",
"card_number": "622700251068005****",
"bank_name": "中国建设银行",
"bank_identification_number": "1050000",
"card_name": "龙卡储蓄卡(银联卡)",
"card_type": "借记卡"
}
}
{
"msg": "入参错误,
"success": false,
"code": 400,
"data": { }
}
格式为 JPG(JPEG),BMP,PNG,GIF,TIFF(小写也可以),宽和高大于 8px,小于等于4000px,大小不能超过1MB
字段名 | 说明 |
---|---|
success | 接口请求成功标识,true为成功,false为失败,失败情况下,会有对应描述和状态码 |
code | 成功为200,其它为失败状态码 |
msg | code对应的说明描述 |
data | 验证结果详细信息 |
order_no | 订单号 |
exif_orientation | exif 信息 |
image_id | 图片上传云端后的id |
card_number | 银行卡号 |
bank_name | 发卡行名称 |
bank_identification_number | 发卡行标识代码 |
card_name | 卡片名称 |
card_type | 卡片类型 |
购买页面上有基于api接口的请求url,入参字段,响应接口结果,和返回错误码描述,请按照要求对接即可