VictorAvelar/fixer-exchange

此包已废弃,不再维护。未建议替代包。

与 Fixer.io 交互的 API 客户端

v1.0.0 2019-03-10 09:09 UTC

This package is auto-updated.

Last update: 2022-03-10 16:43:11 UTC


README

Latest Version on Packagist Software License StyleCI Build Status Coverage Status Quality Score Total Downloads

此包是用于与 fixer.io 免费层服务的 API 包装器。

安装

通过 Composer

$ composer require victoravelar/fixer-exchange

使用

您可以通过执行 示例 文件进行测试运行。

您需要设置一个 API 密钥,您可以在 fixer.io 免费获取一个。

$ php examples.php
<?php // example.php

use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;
use VictorAvelar\Fixer\FixerHttpClient;
use VictorAvelar\Fixer\Resources\CurrencySupportResource;
use VictorAvelar\Fixer\Resources\LatestRatesResource;

require 'vendor/autoload.php';

// Get all supported symbols
$client = new FixerHttpClient('YOUR_KEY_HERE');

$endpoint = new CurrencySupportResource($client);

try {
    $results = $endpoint->execute();
} catch (GuzzleException $e) {
    echo $e->getMessage();
}

echo PHP_EOL;

/** @var ResponseInterface $results */
print_r($results->getBody()->getContents());

// Get the latest exchange rates
$endpoint = new LatestRatesResource($client);

try {
    $latest = $endpoint->execute();
} catch (GuzzleException $e) {
    echo $e->getMessage();
}

print_r($latest->getBody()->getContents());

变更日志

请参阅 CHANGELOG 了解最近更改的详细信息。

测试

$ composer test

贡献

请参阅 CONTRIBUTING行为准则 了解详细信息。

待办事项

  • 实现历史端点
  • 实现货币兑换服务
  • 实现弗勒尔货币原理转换器

安全性

如果您发现任何与安全性相关的问题,请通过电子邮件 deltatuts@gmail.com 而不是使用问题跟踪器。

鸣谢

许可

MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件