| 接口地址:http://zhouxunwang.cn/data/?id=125 |
|---|
| 返回格式:json |
| 请求方式:get |
| 请求示例:http://zhouxunwang.cn/data/?id=125&key=R5RTF4G5F5H6&from=CNY&to=USD&amount=10 |
| 名称 | 类型 | 必填 | 说明 |
|---|---|---|---|
| from | string | 必填 | 要换算的单位 |
| to | string | 必填 | 换算后的单位 |
| amount | string | 必填 | 数量 |
| key | string | 必填 | 平台的KEY 扫码关注公众号 |
| 名称 | 类型 | 说明 |
|---|---|---|
| from | string | 要换算的货币 |
| to | string | 换算后的货币 |
| fromname | string | 要换算的货币名称 |
| toname | string | 换算后的货币名称 |
| updatetime | string | 更新时间 |
| rate | string | 汇率 |
| camount | string | 计算金额 |
{
"status": 0,
"msg": "ok",
"result": {
"from": "CNY",
"to": "USD",
"fromname": "人民币",
"toname": "美元",
"updatetime": "2020-06-05 23:29:27",
"rate": "0.1412",
"camount": 1.4119999999999999
}
}| 错误码 | 说明 |
|---|---|
| 00000 | 没有该接口 |
| 00001 | 参数有空 |
| 00002 | key错误 |
| 00003 | 未办理过该业务 |
| 00004 | 条数不够 |
| 00005 | 已到期 |
| 00006 | 今天条数已用光 |
| 00007 | 您的账号不存在 |
| 201 | 要兑换的货币为空 |
| 202 | 兑换后的货币为空 |
| 203 | 兑换数量为空 |
| 204 | 要兑换的货币有误 |
| 205 | 兑换后的货币有误 |
| 206 | 货币为空 |
| 207 | 货币有误 |
| 208 | 没有信息 |
| 101 | APPKEY为空或不存在 |
| 102 | APPKEY已过期 |
| 103 | APPKEY无请求此数据权限 |
| 104 | 请求超过次数限制 |
| 105 | IP被禁止 |
| 106 | IP请求超过限制 |
| 107 | 接口维护中 |
| 108 | 接口已停用 |
<?php
/**
* Created by PhpStorm.
* User: FZS
* Time: 2020/06/06 17:26
*/
class freeApi
{
private $apiUrl;
public function __construct()
{
$this->apiUrl = 'http://zhouxunwang.cn/data/?id=125&key=R5RTF4G5F5H6&from=CNY&to=USD&amount=10';
}
/**
* 获取结果
* @return array
*/
public function getResult()
{
return file_get_contents($this->apiUrl);
}
}package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
const (
APIURL = "http://zhouxunwang.cn/data/?id=125&key=R5RTF4G5F5H6&from=CNY&to=USD&amount=10"
)
func main() {
queryUrl := fmt.Sprintf("%s",APIURL)
resp, err := http.Get(queryUrl)
if err != nil {
log.Println(err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}