ipaulk / exchange-rates
使用多个网络服务检索货币汇率。
1.1.0
2017-03-22 14:37 UTC
Requires
- php: >=5.5
- guzzlehttp/guzzle: ~6.0
This package is not auto-updated.
Last update: 2024-09-28 20:09:03 UTC
README
使用多个网络服务检索货币汇率。
可用的网络服务
- WebserviceX.NET 数据协议是一种受 SOAP 启发的技术,用于读取、写入和修改网络上的信息。
- Fixer.io 是一个免费的 JSON API,由欧洲中央银行发布,提供当前和历史的外汇汇率。
安装
$ composer require ipaulk/exchange-rates
使用
从 Webservicex.net 获取特定汇率(默认)
use IPaulK\ExchangeRates\ExchangeRates as ExchangeRates; $exchangeRates = new ExchangeRates(); /** @var float $value */ $value = $exchangeRates->getRate('USD', 'EUR');
从 fixer.io 获取特定汇率
use IPaulK\ExchangeRates\ExchangeRates as ExchangeRates; $exchangeRates = new ExchangeRates(); $exchangeRates->setProvider('fixerio'); /** @var float $value */ $value = $exchangeRates->getRate('USD', 'EUR');
请求特定汇率。
use IPaulK\ExchangeRates\ExchangeRates as ExchangeRates; $exchangeRates = new ExchangeRates(); /** @var array $data */ $data = $exchangeRates->fetchRates('USD', ['EUR', 'GBP', 'JPY', 'RUB', 'ILS', 'AUD']);