fastforex/fastforex-php-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

fastforex/fastforex-php-client

最新稳定版本:v1.3.0

Composer 安装命令:

composer require fastforex/fastforex-php-client

包简介

PHP client for fastFOREX.io Currency Exchange Rate API

README 文档

README

Tests Version

You'll need an API key to use the API client. Get a Free Trial API Key.

Installation

With Composer:

composer require fastforex/fastforex-php-client

Quick Start

Set the API key once in your bootstrap code.

\FastForex\Client::setApiKey('YOUR_API_KEY');

Fetch all currencies, with USD base:

$response = (new FastForex\Client())->fetchAll('USD');
print_r($response);
stdClass Object
(
    [base] => USD
    [results] => stdClass Object
        (
            [AED] => 3.67246
            [AFN] => 77.19882
            [ALL] => 101.68772
            ...
        )

    [updated] => 2021-02-15 22:13:51
    [ms] => 5
)

More Examples

Fetch GBP, with USD base:

$response = (new FastForex\Client())->fetchOne('USD', 'GBP');
echo $response->result->GBP;

Fetch several currencies with USD base:

$response = (new FastForex\Client())->fetchMulti('USD', ['GBP', 'EUR', 'CHF']);

Convert 200 USD to GBP:

$response = (new FastForex\Client())->convert('USD', 'GBP', 199.99);

Fetch a list of supported currencies

$response = (new FastForex\Client())->currencies();

Fetch recent API usage

$response = (new FastForex\Client())->usage();

Get all the historical exchange rates for 1st April 2021, with USD base:

$response = (new FastForex\Client())->historical(new \DateTime('2021-04-01'), 'USD');

Get a subset of historical exchange rates for 1st April 2021, with USD base:

$response = (new FastForex\Client())->historical(new \DateTime('2021-04-01'), 'USD', ['EUR', 'GBP', 'CHF']);

Get a 7-day time-series dataset for EUR to CHF

$response = (new FastForex\Client())->timeSeries(
        new \DateTime('2021-04-01'),
        new \DateTime('2021-04-07'),
        'EUR',
        'CHF'
    );

Error Handling

We throw the following Exceptions:

\InvalidArgumentException

Usually when input parameters to the client are wrong

\FastForex\Exception\APIException

When there is problem making the API call, or when there is an error response from the server.

We include the HTTP response code and error message wherever possible:

try {
    \FastForex\Client::setApiKey('invalid key');
    $response = (new FastForex\Client())->fetchAll('USD');
} catch (\FastForex\Exception\APIException $exception) {
    echo $exception->getMessage(), PHP_EOL;
}

Free Trial

Our 7-day free trial API keys are unrestricted. All features and full API quota.

API Documentation

This client implements our OpenAPI spec. Interactive documentation available:

OpenAPI Spec

https://github.com/fastforex/openapi

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-02-15