gufy/currency
货币API (目前为OpenExchangeRate) PHP包装器
v1.0.0
2016-06-10 08:58 UTC
Requires
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-13 18:03:03 UTC
README
目录
安装
只需在命令行运行这个简单的命令
composer require gufy/currency:~1
或者手动更新你的 composer.json
{ "require":{ ... "gufy/currency":"~1" ... } }
用法
该包目前只支持OpenExchangeRates作为主要API。
获取最新的货币汇率
<?php include 'vendor/autoload.php'; use Gufy\Currency\OpenExchange; $api = new OpenExchange("your-app-id"); $rates = $api->rates();
根据日期获取货币汇率
<?php include 'vendor/autoload.php'; use Gufy\Currency\OpenExchange; $date = "2016-06-06"; $api = new OpenExchange("your-app-id"); $rates = $api->rates("USD", $date);
将值转换为某种货币
<?php include 'vendor/autoload.php'; use Gufy\Currency\OpenExchange; $api = new OpenExchange("your-app-id"); $value = 10; $base = "USD"; $target = "IDR"; $rates = $api->convert($value, $base, $target);
获取所有可用的货币
<?php include 'vendor/autoload.php'; use Gufy\Currency\OpenExchange; $api = new OpenExchange("your-app-id"); $rates = $api->currencies();