接口地址:http://route.showapi.com/105-32 |
---|
返回格式:json |
请求方式:get/post |
请求示例:0 |
名称 | 类型 | 必填 | 说明 |
---|---|---|---|
bankCode | String | 必填 | 银行编码 工商银行:ICBC , 中国银行:BOC , 农业银行:ABCHINA , 交通银行:BANKCOMM , 建设银行:CCB , 招商银行:CMBCHINA , 光大银行:CEBBANK , 浦发银行:SPDB , 兴业银行:CIB , 中信银行:ECITIC |
名称 | 类型 | 说明 |
---|---|---|
ame | String | 银行编码 |
time | String | 时间 |
day | String | 日期 |
listSize | String | 货币数量(种) |
codeList | CodeItem[] | 汇率列表 |
ame | String | 货币名称 |
code | String | 货币简码 |
hui_i | String | 现汇买入价 |
chao_i | String | 现钞买入价 |
hui_out | String | 现汇卖出价 |
chao_out | String | 现钞卖出价 |
mid_price | String | 中间价 |
ret_code | String | 0为成功,其他失败 |
{
"showapi_res_code": 0,
"showapi_res_error": "",
"showapi_res_body": {
"time": "01:10:41",
"ret_code": 0,
"name": "ICBC",
"codeList": [{
"hui_in": "6.1854",
"chao_out": "6.2295",
"chao_in": "6.0266",
"hui_out": "6.2295",
"name": "日元",
"mid_price": "--",
"code": "JPY"
}],
"day": "2017-03-30",
"listSize": 23
}
}
错误码 | 说明 |
---|---|
-1 | 系统调用错误 |
-2 | 可调用次数或金额为0 |
-3 | 读取超时 |
-4 | 服务端返回数据解析错误 |
-5 | 后端服务器DNS解析错误 |
-6 | 服务不存在或未上线 |
-1000 | 系统维护 |
-1002 | showapi_appid字段必传 |
-1003 | showapi_sign字段必传 |
-1004 | 签名sign验证有误 |
-1005 | showapi_timestamp无效 |
-1006 | app无权限调用接口 |
-1007 | 没有订购套餐 |
-1008 | 服务商关闭对您的调用权限 |
-1009 | 调用频率受限 |
-1010 | 找不到您的应用 |
-1011 | 子授权app_child_id无效 |
-1012 | 子授权已过期或失效 |
-1013 | 子授权ip受限 |
public static void main(String path[]) throws Exception {
URL u = new URL("http://route.showapi.com/105-32?showapi_appid%3Dmyappid%26bankCode%3Dicbc%26showapi_sign%3Dmysecret");
InputStream in = u.openStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
byte buf[] = new byte[1024];
int read = 0;
while ((read = in .read(buf)) > 0) {
out.write(buf, 0, read);
}
} finally {
if ( in != null) {
in .close();
}
}
byte b[] = out.toByteArray();
System.out.println(new String(b, "utf-8"));
}
<?php
/**
* Created by PhpStorm.
* User: FZS
* Time: 2019/3/15 17:50
*/
//----------------------------------
// 易源 实时汇率表 调用类
//----------------------------------
class freeApi{
private $apiId = false; //易源appid
private $apiSecret = false; //易源secret
private $apiUrl = 'http://route.showapi.com/105-32';
public function __construct($apiid,$secretkey){
$this->apiId = $apiid;
$this->apiSecret = $secretkey;
}
/**
* url拼接
* @return string
*/
private function handleParam($paramArr,$showapi_secret){
$paraStr = "";
$signStr = "";
ksort($paramArr);
foreach ($paramArr as $key => $val) {
if ($key != '' && $val != '') {
$signStr .= $key.$val;
$paraStr .= $key.'='.urlencode($val).'&';
}
}
$signStr .= $showapi_secret;//排好序的参数加上secret,进行md5
$sign = strtolower(md5($signStr));
$paraStr .= 'showapi_sign='.$sign;//将md5后的值作为参数,便于服务器的效验
return '?'.$paraStr;
}
/**
* 将JSON内容转为数据,并返回
* @param string $content [内容]
* @return array
*/
public function returnArray($content){
return json_decode($content,true);
}
/**
* 获取 实时汇率表 结果
* @return array
*/
public function getResult(){
$paramArr = [
'showapi_appid'=> $this->apiId,
'bankCode'=> "icbc"
];
return $this->returnArray($this->freeApiCurl($this->apiUrl.$this->handleParam($paramArr,$this->apiSecret)));
}
/**
* 请求接口返回内容
* @param string $url [请求的URL地址]
* @param string $params [请求的参数]
* @param int $ipost [是否采用POST形式]
* @return string
*/
public function freeApiCurl($url,$params=false,$ispost=0){
$ch = curl_init();
curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
curl_setopt( $ch, CURLOPT_USERAGENT , 'free-api' );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );
curl_setopt( $ch, CURLOPT_TIMEOUT , 60);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );
if( $ispost )
{
curl_setopt( $ch , CURLOPT_POST , true );
curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );
curl_setopt( $ch , CURLOPT_URL , $url );
}
else
{
if($params){
curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );
}else{
curl_setopt( $ch , CURLOPT_URL , $url);
}
}
$response = curl_exec( $ch );
if ($response === FALSE) {
return false;
}
curl_close( $ch );
return $response;
}
}
//推荐使用npm安装使用sdk: npm install --save showapi-sdk
'use strict';
var showapiSdk = require('showapi-sdk');
//设置你测试用的appId和secret,img
var appId='';
var secret='';
//开启debug
//showapiSdk.debug(true);
if(!(appId&&secret)){
console.error('请先设置appId等测试参数,详见样例代码内注释!')
return;
}
//全局默认设置
showapiSdk.setting({
url:"http://route.showapi.com/105-32",//你要调用的API对应接入点的地址,注意需要先订购了相关套餐才能调
appId:appId,//你的应用id
secret:secret,//你的密钥
timeout:5000,//http超时设置
options:{//默认请求参数,极少用到
testParam:'test'
}
})
var request=showapiSdk.request();
request.appendText('bankCode','icbc');
request.post(function(data){
console.info(data)
})
package main
import (
"showSdk/normalRequest"
"fmt"
)
res := normalRequest.ShowapiRequest("http://route.showapi.com/105-32",my_appId,"my_appSecret")
res.AddTextPara("bankCode","icbc")
//res.AddFilePara("img", "C:\\Users\\showa\\Desktop\\使用过的\\4.png")//文件上传时设置
fmt.Println(res.Post())
# python3.6.5
# 需要引入requests包 :运行终端->进入python/Scripts ->输入:pip install requests
from ShowapiRequest import ShowapiRequest
r = ShowapiRequest("http://route.showapi.com/105-32","my_appId","my_appSecret" )
r.addBodyPara("bankCode", "icbc")
# r.addFilePara("img", r"C:\Users\showa\Desktop\使用过的\4.png") #文件上传时设置
res = r.post()
print(res.text) # 返回信息