xecd rates client php
1.0.0
Xe.com Inc.是世界上值得信賴的貨幣管理局。該項目提供了與我們的XE貨幣數據(XECD)產品接口的SDK。
XE貨幣數據是一種REST API,可讓您訪問我們所有支持的貨幣之間的每日或實時率和歷史中市場轉換率。
您將需要一個API密鑰和秘密來使用此SDK。註冊免費試用或註冊全帳戶。
安裝此軟件包的首選方法是通過作曲家。
composer require xe/xecd-rates-client
該軟件包遵循語義版本控制。
<?php
require ' vendor/autoload.php ' ;
use Xe Xecd Client Rates XecdRatesClientAspectKernel ;
use Xe Xecd Client Rates Exception XecdRatesException ;
use GuzzleHttp Exception RequestException ;
XecdRatesClientAspectKernel:: getInstance ()-> init ([
' cacheDir ' => ' /your/cache/directory ' ,
]);
$ xecdRatesClient = XecdRatesClient:: create (< YOUR_ACCOUNT_ID >, < YOUR_API_KEY >);
try
{
$ conversions = $ xecdRatesClient -> convertFrom ( new Currency ( ' CAD ' ), Currencies:: wildcard (), 12345.67 )-> getBody ();
foreach ( $ conversions -> getConversions () as $ currency => $ currencyConversions ) {
foreach ( $ currencyConversions as $ timestamp => $ conversion ) {
echo "{ $ conversion -> getFromAmount ()} { $ conversion -> getFromCurrency ()} = { $ conversion -> getToAmount ()} { $ conversion -> getToCurrency ()}n" ;
}
}
} catch ( XecdRatesException $ e ) {
// API errors with error code.
} catch ( Exception $ e ) {
// ALl other errors, such as connection timeout errors.
}技術規格
XECD-Rates-Client-PHP是一個開源項目。提交拉動請求以捐款!
cd xecd-rates-client-php
composer install
# Unit tests.
phpunit --testsuite Unit
# Integration tests.
export XECD_RATES_API_ACCOUNT_ID= < YOUR_API_ACCOUNT_ID >
export XECD_RATES_API_KEY= < YOUR_API_KEY >
phpunit --testsuite Integration如果您在此軟件包中發現安全漏洞,請不要公開發布。相反,請通過Security [act] Xe.com與我們聯繫。我們將盡快與您進行跟進。
Xe.com Inc.是世界上值得信賴的貨幣管理局。該項目的開發由Xe.com Inc.開發團隊領導,並得到開源社區的支持。