定制 rubin/openexchangerates 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rubin/openexchangerates

最新稳定版本:1.1.0

Composer 安装命令:

composer require rubin/openexchangerates

包简介

OpenExchangeRates API connector

README 文档

README

Build Status Latest Stable Version Coverage Status PHP Version Require GitHub License

PHP implementation for the OpenExchangeRates.org REST API. This library is based on the REST API docs.

Installation

With composer:

composer require rubin/openexchangerates

Usage

Create API connector:

$api = new OpenExchangeRates\OpenExchangeRatesApi('{APP_ID}');

Extra parameters

Set Base Currency ('base')

The default base currency of the API is US Dollars (USD), but you can request exchange rates relative to a different base currency, where available, by setting the base parameter in your request.

$api->setBase('EUR');

Get Specific Currencies ('symbols')

By default, the API returns rates for all currencies, but if you need to minimise transfer size, you can request a limited subset of exchange rates, where available, by setting the symbols parameter in your request.

$api->setSymbols(['AMD', 'EUR']);

Alternative Rates ('show_alternative')

You may now request latest and historical rates for unofficial, black market and alternative digital currencies by adding a simple API parameter onto your request.

$api->setShowAlternative(true);

API endpoints

/latest

Get the latest exchange rates available from the Open Exchange Rates API.

The most simple route in our API, latest.json provides a standard response object containing all the conversion rates for all of the currently available symbols/currencies, labeled by their international-standard 3-letter ISO currency codes.

The latest rates will always be the most up-to-date data available on your plan.

echo "Symbol\tRate\n";
foreach ($api->getLatest()->rates as $symbol => $rate) {
    printf("%s\t%s\n", $symbol, $rate);
}

/historical

Get historical exchange rates for any date available from the Open Exchange Rates API, currently going back to 1st January 1999.

The historical rates returned are the last values published for a given UTC day (up to and including 23:59:59 UTC), except for the current UTC date.

echo "Symbol\tRate\n";
foreach ($api->getHistorical(new \DateTimeImmutable('2012-07-10'))->rates as $symbol => $rate) {
    printf("%s\t%s\n", $symbol, $rate);
}

/currencies

Get a JSON list of all currency symbols available from the Open Exchange Rates API, along with their full names, for use in your integration.

This list will always mirror the currencies available in the latest rates (given as their 3-letter codes).

echo "Symbol\tName\n";
foreach ($api->getCurrencies() as $symbol => $name) {
    printf("%s\t%s\n", $symbol, $name);
}

/usage

Get basic plan information and usage statistics for an Open Exchange Rates App ID

var_dump($api->getUsage());

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-10-05