| 参数 | 值 |
|---|---|
| appid | 开通后系统自动分配 |
| sign | 开通后系统自动分配 |
| 参数 | 是否必填 | 类型 | 可选值范围 | 说明 |
|---|---|---|---|---|
| cnaps | 是 | int | 12位联行号 | 如:308584001016 |
import okhttp3.*;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
public class OkHttpClientExample {
// 创建全局 OkHttpClient 实例 (建议单例模式)
private static final OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(5, TimeUnit.SECONDS)
.readTimeout(5, TimeUnit.SECONDS)
.build();
public static void main(String[] args) {
String path = "/bank/reverse";
// 【重要】请替换为真实值
String appid = "你的真实AppId";
String sign = "你的真实Sign";
// 构建 HttpUrl (自动处理参数拼接和编码)
HttpUrl url = new HttpUrl.Builder()
.scheme("https")
.host("api.cwjyz.com.cn") // 注意:host 中不要带 https://
.addPathSegments(path.substring(1)) // 去掉开头的 /
.addQueryParameter("appid", appid)
.addQueryParameter("sign", sign)
.addQueryParameter("cnaps", "308584001016") // 填写自己要查的12位联行号
.build();
Request request = new Request.Builder()
.url(url)
.get()
.build();
try (Response response = client.newCall(request).execute()) {
if (!response.isSuccessful()) {
throw new IOException("Unexpected code " + response);
}
String responseBody = response.body().string();
System.out.println("请求成功:");
System.out.println(responseBody);
} catch (IOException e) {
e.printStackTrace();
}
}
}
function get_reverse($cnaps = '') {
$baseUrl = 'https://api.cwjyz.com.cn/bank/reverse';
// 【重要】请替换为你真实的 AppId 和 Sign
$appid = "你的真实AppId";
$sign = "你的真实Sign";
// 1. 构建参数字典
$params = array(
'appid' => $appid,
'sign' => $sign,
'cnaps' => $cnaps // 12位联行号,如:308584001016
);
// 2. 拼接查询字符串
$queryString = http_build_query($params);
$fullUrl = $baseUrl . '?' . $queryString;
// 3. 初始化 CURL
$curl = curl_init();
// 4. 设置 CURL 选项
curl_setopt($curl, CURLOPT_URL, $fullUrl);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 跳过 SSL 证书验证 (开发环境常用,生产环境建议配置证书)
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // 返回字符串而不是直接输出
curl_setopt($curl, CURLOPT_TIMEOUT, 20); // 设置超时时间 20 秒
// 5. 执行请求
$output = curl_exec($curl);
// 6. 网络层错误处理
if ($output === false) {
$error = curl_error($curl);
curl_close($curl);
throw new Exception("CURL 请求失败: " . $error);
}
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
// 7. 业务层状态码处理
if ($httpCode != 200) {
return ["error" => "HTTP Status: " . $httpCode, "response" => $output];
}
// 8. 解析 JSON 并返回数组
return json_decode($output, true);
}
import urllib.request
import urllib.parse
# 配置参数(请替换为真实值)
host = 'https://api.cwjyz.com.cn'
path = '/bank/reverse'
appid = '您的真实Appid'
sign = '您的真实Sign'
# 如下变量请替换为真实值:
params = {
'appid': appid,
'sign': sign,
'cnaps': '308584001016' # 填写自己要查的12位联行号
}
query_string = urllib.parse.urlencode(params)
url = host + path + '?' + query_string
request = urllib.request.Request(url)
with urllib.request.urlopen(request) as response:
content = response.read().decode('utf-8')
print(content)
| 字段 | 是否必备 | 类型 | 说明 |
|---|---|---|---|
| code | 是 | int | 状态码: - 200 请求成功,返回数据 - 204 联行号不存在或失效 以上2种均属调用成功,扣减次数 |
| msg | 是 | string | 提示信息 |
| query_id | 是 | bigint | 唯一的请求编号 |
| remaining | 否 | int | 该API接口剩余可使用次数 |
| result | 否 | array | 数据结果 |
| + total_items | 否 | int | 符合条件的元素总数 |
| + data | 否 | array[] | 符合条件的银行信息 |
| ++ bank | 否 | string | 所属银行总行 |
| ++ provi | 否 | string | 所在省份 |
| ++ city | 否 | string | 所在城市 |
| ++ name | 否 | string | 具体银行完整名称 |
| ++ cnaps | 否 | int | 联行号 |
| ++ status | 否 | int | 状态 0:无效 1:有效 |
| ++ address | 否 | string | 地址 |
| ++ tel | 否 | string | 电话 |
| ++ open_date | 否 | string | 成立时期 |
{
"code": 200,
"msg": "success",
"query_id": "651733048416",
"remaining": 99998,
"result": {
"total_items": 1,
"data": [
{
"bank": "招商银行股份有限公司",
"provi": "广东省",
"city": "深圳市",
"name": "招商银行深圳分行",
"cnaps": 308584001016,
"status": "1",
"address": "深圳市福田区莲花街道深南大道2016号招商银行深圳分行大厦",
"tel": "0755-88023111",
"open_date": "2005-11-30"
}
]
}
}
| 代码 | 说明 |
|---|---|
| 401 | 无效appid |
| 403 | 签名sign验证错误 |
| 405 | 剩余可使用次数为0 |
| 4001 | 缺少参数cnaps,或值为空 |
| 4002 | 参数值错误,须为12位数字 |
©2026 财务加油站 粤ICP备2022016929号 深圳晓芽科技有限公司增值电信业务经营许可证:粤B2-20221644