SDK接入示例

你可以点击右上角的开发语言来切换各种开发语言的示例代码^_^

第一步:设置SDK密钥信息

本代码中的值仅为示例,实际使用请替换为开发者申请的真实KEYID及密钥

Java版SDK的配置可以在com.cib.fintech.dfp.open.sdk.config类中更改,或使用相应的setter进行设置。

注意:Java使用PKCS8格式的RSA私钥,并且不包含头部“-----BEGIN PRIVATE KEY-----”和尾部“-----END PRIVATE KEY-----”的标识符以及换行。

Configure.setKeyId("KYONLYFORTEST012345678");
Configure.setPriKey("MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCD+nV2C5SAD0gMgEVmxxpk8GxYpfG5SaIaukgsnyr1OLx+0U6y+vUeZ/T0jnxZvvz0jX06QSzBwEAhfFUqz+fXOvktgAS4KK9qa+1YbMjDXuIjNSpfoTrJplRI1Wg8x+O+dy1A10ktlkg3OHGiXr8kpLMYH/C4TfLdk9+GZBnGKEzRcaq7kUEWMY/4oz1pXgxaC0f2HR8Km7vpeT9Mohhu4hLPqyn4f1ugH/chfOKsoU3nnMsZecN+m3MP1yOgY3q3wOEoNwoS2Yy8PqtiQotPIxHHhbbWiqPvCt+cS44roGyTKKxuQLBiSmEui8UIMHT+G64LzL7Yn/SxZmTVvkeTAgMBAAECggEALVCDoCJdvJKCpHguXBmkwF+kc9OWaY4UsKShP2DvOP9gCRMIuH9eRjBfdNCvdYkUBUvHYYcbPPMrkdPE0kxMSCQhhjPcavbdM+cWuTOwwxQDBR+uCuOq8a3AZrmPbr8bPTxiN08z+wkMhplEuwFZE9XRAEmHN2DcMKQjLVuVVenlt07AYVWtO2T01gn4ZCXhy8thDUWooh0D5RckZJ88DBgvP+/+Sb2zuFEfXEGZJD+EizmECZlaENzapRANU55QuRFEiqjhyJrKXbfHj3xRWMf0jvS3qLX+pmgBRPLMhvA2jDlNiMRSegTkpzv75/Lel5mb12YYL+7koadNXl5gIQKBgQDILRuZZSHpABbWJCEUfy4FusT7aA6SMyCrUHO+ikCST02UVGLgMzsyguvGJe7PcxsK00wyG5kwnk6STz3xcEvIzKuW702d9lHkZ1BvHXAtAMnbWYEZ4m2zgL6Ydm3vOYvxm1aRZsZkw64fgOvSDRT+LtulC/qK8NUOZiRVis5WawKBgQCoyJmakC7JLpXGPgHkrPRpiROYM/evFqAy0V7FXSebytff7v4hwAh2InNKYfUtntx3VfVF+WEFcBHFFcHIrvhnrjeyncjnCCiyLaIzijLbTSxZpFDxt4wNTO8PdYw8yjUXjYppdbhgKYFPCHjvxf3g28Mlub2vDBhM+XW4rHwNeQKBgQCa09jfAowB7eG76+HyOpRcNiOZ2Ng8WHNSTj3YCJL9F32H1uVLSBTncr/uWPSnW/50lw3+S75nDmrzW3srvZHAVB379kfwf87DfO2HpBtZk5yNnmLupGX5SwEgZ6mMONR3IZEJkZat5XRORacgpqGwIIoe1G8K/E+ufW5pA52o1QKBgDf1SffUla5do4p2RGpsbRwQNk7f695AwhwXDjShDeC4/5lewyKtaCDCiza+A2t8n9twxEDOzTvgTAPrkrPWTsURHaY6acEvE07/kidESlgq3elacPuyvtwqBZg6gKQm5jNI2frc7KP1Hsn1JSNZoTJLqgd37Ut71xKuIjl39ikBAoGABoG2VQzgt+6ZsL38++cjc4lZUKE2+6MQjlgHl6v8oXEQ/1ix5S+/JPjZPrMsgK9YZ6QxrjEr1LrHH5v/wE2GJNHjId2axpD6UUQcOx7R9C6m2wylzD3iimP/PhpmOyknuQHULCDd8XeRZx+kbm1lrermq7n0AUvuwPlmR93mYxY=");

PHP版SDK的配置可以在open_config.php文件中修改相应的KEYID和密钥信息。

注意:PHP使用标准PKCS1格式的RSA私钥。头部为“-----BEGIN RSA PRIVATE KEY-----”。
注意:PHP需要打开php_curl和php_openssl扩展。

$open_config['keyid'] = 'KYONLYFORTEST012345678';
$open_config['privateKey'] = '-----BEGIN RSA PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCLcuCIrwldp1Zw
t0IdBNyxQ93hcQowGVYI/QX4mL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gp94XgSLy7CYkGpRvQ+KRD94NdDcNqzAtrgSVu2+Y0Dxa8O4HG4fjx
FS65ufoklq1/tHOMdL2GuzbmHg6k1/rfrGR/lWZtYJi1nfeXoUh0kmpNAoGARD/R
fGz4pRFD2iZXKzKlb65k0Q5KbWAYWDkGcCYyz2SxcYDUHnGbWWF2xymB7CIQl4IR
loarK9omIYM3F73c2etnrbdwHa43RcJThKxF2gMGSzgMjSqbOawrrkx8cqPEmhyq
B5ERoxZeaSnrDJpLqPXOD0vhG1RtUA2KCws2VikCgYBHmsH0FmnfrvYcnkVweYo0
oej98xMKCx3tpyXV/fbVXDVEqXXM4LQ1Qb7qeTMmfLJKNKvksQZk2guQoCyjN5sJ
6UOBMfhkYXUp/dy0zzAIh2NzjkXpocsp5ujWcV+rAHnrW6UFwRdDDSlM1ov+VLS0
KquHpZIjghtC0a4u6Dxxsw==
-----END RSA PRIVATE KEY-----';

Python2.x版SDK,可以在opensdk.py文件中的OpenSdkConfig类中修改KEYID和对应的私钥。

注意:Python2.x使用标准PKCS1格式的RSA私钥。头部为“-----BEGIN RSA PRIVATE KEY-----”。
注意:Python2.x需要安装rsa扩展,可以使用pip install rsa进行安装。

self.keyid = 'KYONLYFORTEST01234567890'
self.key = '''-----BEGIN RSA PRIVATE KEY-----
MIIEqQIBAAKCAQEAkgZvePcnldMCXBySUEVD9+F8r8HsKZqfwhQLDJNZB/Qefk8k
PN0BllFzVQqCEzMbNZFUmoJZzFcwpfeDvgammTY53cTqpTZK5F03Yxrvlub1arZs
KDrVw52dnKQJqK8Qmkt8yCa3CxamBHEeRCCDvrurq/EhJwWgZnCFCTKmNGXy9DLx
k9GTL69VJbYAIpU2q/3VCc21+TxH/drZAe3fu99KVZzoDMMMLQsDwjclbgFjLcRN
iV+Qhmun4MeI98n3dtiAU3eNiG4z1Jz6VLo1hrHI4HaTodcTk27hir7mlXeTkyX/
wY2/D9InzEnkgXhQomUsh5BRQcGyqjojIeqJzQIDAQABAoIBAACZcCmx8gKmb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8/DM+qKUN7ziH2kRZA7w5xrAd2wW7eCS
zHYi4mkQCYXkKlUlPJwbsQ0w2nt6r1CoqDLb6WaMfn/h1FcTBKl5Ig3ppfB+GciD
LeHyq6xJduaDRjgdQRKmGBvlVpnnNj99oEslCyZBL1kbHaAQTpljYVyl1+8s
-----END RSA PRIVATE KEY-----
'''

Python3.x版SDK,可以在opensdk.py文件中的OpenSdkConfig类中修改KEYID和对应的私钥。

注意:Python3.x使用标准PKCS1格式的RSA私钥。头部为“-----BEGIN RSA PRIVATE KEY-----”。
注意:Python3.x需要安装rsa扩展,可以使用pip install rsa进行安装。

self.keyid = 'KYONLYFORTEST01234567890'
self.key = '''-----BEGIN RSA PRIVATE KEY-----
MIIEqQIBAAKCAQEAkgZvePcnldMCXBySUEVD9+F8r8HsKZqfwhQLDJNZB/Qefk8k
PN0BllFzVQqCEzMbNZFUmoJZzFcwpfeDvgammTY53cTqpTZK5F03Yxrvlub1arZs
KDrVw52dnKQJqK8Qmkt8yCa3CxamBHEeRCCDvrurq/EhJwWgZnCFCTKmNGXy9DLx
k9GTL69VJbYAIpU2q/3VCc21+TxH/drZAe3fu99KVZzoDMMMLQsDwjclbgFjLcRN
iV+Qhmun4MeI98n3dtiAU3eNiG4z1Jz6VLo1hrHI4HaTodcTk27hir7mlXeTkyX/
wY2/D9InzEnkgXhQomUsh5BRQcGyqjojIeqJzQIDAQABAoIBAACZcCmx8gKmbBMO
tvcHYcEJtuZNyHdfQBqe1HDHxgzHTry7/G0XhyMj0HJf6arEge8VWqCLumyhSvzT
aEIGavakB1bGsSPedi47x7dra+JVrloyx3zeyPPVmMkEz1lW5p2Lg8aaihPMkv/f
qv0imQfWY10AT1+GoWIAwfszbuH+SDIBU4DIvNh1UBeibYD3pS/sizuk5dqcNGjY
v3Dp8o3ENNQfE06luXrrIhZBOpcg1RLKM7fClUzc8OifygHtRNGB8FkTUR7AxlwE
xtxTtFLd53k9GmMCXp7lSBhLMO/pQU2wZx9p2dFBfQBAbC8X2UvnryFm2DEfXMRU
zjPJmQ0CgYkA3jdvL9JzXDYvlnBRl2VvyQxLHUNzfe9Li7cGnIdNqGVPaG24qT9K
tmqXoKJ/cXSAtrz8qO/u0TRiH2awqNzGfRzB4kZfnCjy1RiQJ+NJObgIE+xEvdOS
C023ZNBaM9Wck5zfHEt01pprFpWZkrteKFCLAXOSWa8WBSmQ67fg795kQ3HIyOHW
SwJ5AKg5qrBGy4ZdvJtbGHOdID+i4lyskHX9BqLDhnACFv57n5hAyBXfq6AVZpvw
qQcDqelJYcQhEC8PUCMMtPBkmQrDQ+Q26w/kmpRHl6aUrvOKu2STfWfN9eDCtfGm
Hqsj5U/hj24sjKHW7D16N/GRqOoSvNcSaHNxRwKBiQCmPwa52lJf3FIB1InWIBdf
bAkOHZZb0xjLr+QMWtVodFLSJ7QNOsKkcl552NhLgwOAsya7JLWgYfY+0866pmEA
3PDYXhnNdH0nm7bNgKcZvWqdrRdIhO4v8raPf6jcOqVncecg/fqtSt1vCgDY28B3
nLpCHbqRygFJX22CTBDGo7STGJ9EWmC9AnhTQv+FcfTIE1sHdaX7ixhsBr2M6ugx
TcPcCXRfudkRqbRLEj01/leeyxjXM90lGJ4fVe+quEafVC/wuRhRJylMV2sh6ECd
xCLyIyEfFNYmulKXrBxUpW7+CMEu0m65e/HCgLyR5kDQ1WRl5TkNOm/lMtL+jCDg
in8CgYgCxSDLLUE9k93zjqoEw83wfZDJ8/DM+qKUN7ziH2kRZA7w5xrAd2wW7eCS
zHYi4mkQCYXkKlUlPJwbsQ0w2nt6r1CoqDLb6WaMfn/h1FcTBKl5Ig3ppfB+GciD
LeHyq6xJduaDRjgdQRKmGBvlVpnnNj99oEslCyZBL1kbHaAQTpljYVyl1+8s
-----END RSA PRIVATE KEY-----
'''

C#版SDK可以在Com.Cib.Fintech.Dfp.Open.Sdk.Config.Configure类中修改对应的KEYID和私钥。

注意:C#版SDK使用PKCS8格式的RSA私钥,并且不包含头部“-----BEGIN PRIVATE KEY-----”和尾部“-----END PRIVATE KEY-----”的标识符以及换行。
注意:C#版SDK需要导入开源库BouncyCastle1.8.1,下载地址:http://www.bouncycastle.org/csharp/

private static String keyId = "KYONLYFORTEST012345678";
private static String priKey =  "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCD+nV2C5SAD0gMgEVmxxpk8GxYpfG5SaIaukgsnyr1OLx+0U6y+vUeZ/T0jnxZvvz0jX06QSzBwEAhfFUqz+fXOvktgAS4KK9qa+1YbMjDXuIjNSpfoTrJplRI1Wg8x+O+dy1A10ktlkg3OHGiXr8kpLMYH/C4TfLdk9+GZBnGKEzRcaq7kUEWMY/4oz1pXgxaC0f2HR8Km7vpeT9Mohhu4hLPqyn4f1ugH/chfOKsoU3nnMsZecN+m3MP1yOgY3q3wOEoNwoS2Yy8PqtiQotPIxHHhbbWiqPvCt+cS44roGyTKKxuQLBiSmEui8UIMHT+G64LzL7Yn/SxZmTVvkeTAgMBAAECggEALVCDoCJdvJKCpHguXBmkwF+kc9OWaY4UsKShP2DvOP9gCRMIuH9eRjBfdNCvdYkUBUvHYYcbPPMrkdPE0kxMSCQhhjPcavbdM+cWuTOwwxQDBR+uCuOq8a3AZrmPbr8bPTxiN08z+wkMhplEuwFZE9XRAEmHN2DcMKQjLVuVVenlt07AYVWtO2T01gn4ZCXhy8thDUWooh0D5RckZJ88DBgvP+/+Sb2zuFEfXEGZJD+EizmECZlaENzapRANU55QuRFEiqjhyJrKXbfHj3xRWMf0jvS3qLX+pmgBRPLMhvA2jDlNiMRSegTkpzv75/Lel5mb12YYL+7koadNXl5gIQKBgQDILRuZZSHpABbWJCEUfy4FusT7aA6SMyCrUHO+ikCST02UVGLgMzsyguvGJe7PcxsK00wyG5kwnk6STz3xcEvIzKuW702d9lHkZ1BvHXAtAMnbWYEZ4m2zgL6Ydm3vOYvxm1aRZsZkw64fgOvSDRT+LtulC/qK8NUOZiRVis5WawKBgQCoyJmakC7JLpXGPgHkrPRpiROYM/evFqAy0V7FXSebytff7v4hwAh2InNKYfUtntx3VfVF+WEFcBHFFcHIrvhnrjeyncjnCCiyLaIzijLbTSxZpFDxt4wNTO8PdYw8yjUXjYppdbhgKYFPCHjvxf3g28Mlub2vDBhM+XW4rHwNeQKBgQCa09jfAowB7eG76+HyOpRcNiOZ2Ng8WHNSTj3YCJL9F32H1uVLSBTncr/uWPSnW/50lw3+S75nDmrzW3srvZHAVB379kfwf87DfO2HpBtZk5yNnmLupGX5SwEgZ6mMONR3IZEJkZat5XRORacgpqGwIIoe1G8K/E+ufW5pA52o1QKBgDf1SffUla5do4p2RGpsbRwQNk7f695AwhwXDjShDeC4/5lewyKtaCDCiza+A2t8n9twxEDOzTvgTAPrkrPWTsURHaY6acEvE07/kidESlgq3elacPuyvtwqBZg6gKQm5jNI2frc7KP1Hsn1JSNZoTJLqgd37Ut71xKuIjl39ikBAoGABoG2VQzgt+6ZsL38++cjc4lZUKE2+6MQjlgHl6v8oXEQ/1ix5S+/JPjZPrMsgK9YZ6QxrjEr1LrHH5v/wE2GJNHjId2axpD6UUQcOx7R9C6m2wylzD3iimP/PhpmOyknuQHULCDd8XeRZx+kbm1lrermq7n0AUvuwPlmR93mYxY=";

C/C++版SDK,可以参考Example.c中的编码。将KEYID和RSA私钥作为char*类型的全局参数进行定义即可。

注意:C/C++使用标准PKCS1格式的RSA私钥。头部为“-----BEGIN RSA PRIVATE KEY-----”。

进入sdk所在路径,执行make即可编译产生可执行文件open。

char* keyId = "KYONLYFORTEST012345678";
char* priKey = "-----BEGIN RSA PRIVATE KEY-----\n"\
"MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCFPUk4XHdBQhkW\n"\
"XPuTNSwjn+X5VFbYPPAjgCZexsAUwiehjgzGMRy83D13nXnhTxu+ohpUpHSD3pa6\n"\
"IkaRxrhStcbZANthY3pbeDkSuq573ellxgPujCqaMjkV3fVBJ8OAH2rZXm9aA+Fr\n"\
"/qYOm7NAcIQuLWTLfvOq5w7ocLq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7FdVf1VHhY2qh3j20\n"\
"sutHLjWjaia79Q9uVdtTVcc6HVC8cUmKguBTf2wL8eqIoD3+IPnfqopBAoGAMUfx\n"\
"5LkzX1V1IYZ29qjlRnf23nFQFOCXp61PFX0weY88dXw4YL3TdxwY1HrgFnrh9qfT\n"\
"3IcB95UU457K2kEl9/eQFTaiHg1xHMKuO2L8SpHupgkvlKRQ8aakt8Grus4gl6vq\n"\
"b4NsIBofmZAjFeEtu08eWfXbHbSA87KPBwUcO7UCgYAmiBi8aBckhqyp+kfNnRum\n"\
"8tMATlz6x/HtFWKBxc5+BLa5SXSmadf8LEKiZQpY3tcyyTm9/omlQ/TBW91riVHE\n"\
"T+iJfjhkvDMHbsy4Ux2k5zLdcieAkceppETcp6wMUjX1uf8tJzQQrBtTz2Llpml/\n"\
"vJeDqlKmKG+81ZxSulNPJg==\n"\
"-----END RSA PRIVATE KEY-----\n";

第二步:准备请求参数

开发者根据请求资源,准备不同的参数集合。根据接口不同,可能包括HEADER请求参数、GET请求参数、POST请求参数三种参数。

Map<String, String> bodyParams = new HashMap<String, String>();
bodyParams.put("mobile", "13000000000");
// 实例化
$open = new OpenSDK($open_config);

// 组装参数等
$body_param_array = array('content' => '这是短信内容', 'smsId' => '10000001', 'mobile' => '13000000000', 'isp' => 'CIB', 'priority' => 'NORMAL', 'type' => 'TEXT');
body_params = {'type': 'TEXT'}
body_params = {'type': 'TEXT'}
Dictionary<String, String> bodyParams = new Dictionary<String, String>();
bodyParams.Add("mobile", "13900000000");
bodyParams.Add("content", "短信内容");
bodyParams.Add("type", "TEXT");
Map headParams[N];
Map bodyParams[N];

/* 变量初始化 */
map_init(headParams);
map_init(bodyParams);

/* 变量赋值 */
strcpy(headParams[0].name, "charset");
strcpy(headParams[0].value, "utf-8");

strcpy(bodyParams[0].name, "mobile");
strcpy(bodyParams[0].value, "13000000000");
strcpy(bodyParams[1].name, "type");
strcpy(bodyParams[1].value, "TEXT");
strcpy(bodyParams[2].name, "content");
strcpy(bodyParams[2].value, "hhh");
strcpy(bodyParams[3].name, "priority");
strcpy(bodyParams[3].value, "HIGH");

第三步:调用SDK方法

传入请求资源URI、请求方法,以及各位置的参数。返回值即为响应结果。

String response = OpenSDK.gateway("/api/test", ReqMethodEnum.POST, null, null, bodyParams);
$result = $open->exec('/api/test', 'POST', null, null, $body_param_array);
print(opensdk.opensdk(conf, '/api/test', 'POST', None, None, body_params))
print(opensdk.opensdk(conf, '/api/test', 'POST', None, None, body_params))
String response = OpenSDK.gateway("/api/test", ReqMethodEnum.Post , null, null, bodyParams);
char* response = gateway("/api/test", reqMethod, headParams, bodyParams);
© CIB FINTECH CO.,LTD All Rights Reserved.Last Update: 2018-08-03

results matching ""

    No results matching ""