| 参数名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| from | string | 是 | 要换算的单位 |
| to | string | 是 | 换算后的单位 |
| amount | string | 是 | 数量 |
| 参数名称 | 类型 | 说明 |
|---|---|---|
| from | string | 要换算的货币 |
| to | string | 换算后的货币 |
| fromname | string | 要换算的货币名称 |
| toname | string | 换算后的货币名称 |
| updatetime | string | 更新时间 |
| rate | string | 汇率 |
| camount | string | 计算金额 |
<?php
require_once 'curl.func.php';
$appkey = 'your_appkey_here';//你的appkey
$from = 'CNY';
$to = 'USD';
$amount = 10;
$url = "https://api.binstd.com/exchange/convert?appkey=$appkey&from=$from&to=$to&amount=$amount";
$result = curlOpen($url, ['ssl'=>true]);
$jsonarr = json_decode($result, true);
//exit(var_dump($jsonarr));
if($jsonarr['status'] != 0)
{
echo $jsonarr['msg'];
exit();
}
$result = $jsonarr['result'];
echo $result['from'].' '.$result['to'].' '.$result['fromname'].' '.$result['toname'].' '.$result['updatetime'].' '.$result['rate'].' '.$result['camount'].'
';
{
"status": "0",
"msg": "ok",
"result": {
"from": "CNY",
"to": "USD",
"fromname": "人民币",
"toname": "美元",
"updatetime": "2015-10-26 16:56:22",
"rate": "0.1574",
"camount": "1.574"
}
}
| 代号 | 说明 |
|---|---|
| 201 | 要兑换的货币为空 |
| 202 | 兑换后的货币为空 |
| 203 | 兑换数量为空 |
| 204 | 要兑换的货币有误 |
| 205 | 兑换后的货币有误 |
| 206 | 货币为空 |
| 207 | 货币有误 |
| 208 | 没有信息 |
| 代号 | 说明 |
|---|---|
| 101 | APPKEY为空或不存在 |
| 102 | APPKEY已过期 |
| 103 | APPKEY无请求此数据权限 |
| 104 | 请求超过次数限制 |
| 105 | IP被禁止 |
| 106 | IP请求超过限制 |
| 107 | 接口维护中 |
| 108 | 接口已停用 |
| 会员等级 | 权限 |
|---|---|
| 普通用户 | 100次 |
| 会员 | 不限次 |
| 技术代理 | 不限次 |
开通账号: