ranium/fixerio-php-client
Composer 安装命令:
composer require ranium/fixerio-php-client
包简介
A PHP client for fixer.io foreign exchange rates and currency conversion API.
README 文档
README
Fixer.io PHP Client
Provides an easy to use client for fixer.io exchange rates and currency conversion JSON API.
Looking for a Laravel package? Please use ranium/laravel-fixerio instead of this library.
Installation
This project can be installed using Composer:
composer require ranium/fixerio-php-client
Usage
This package uses's Guzzle's Service Description to make HTTP Requests to the fixer.io API.
To use this package in your application, simply use the package and instantiate the client as follows
use Ranium\Fixerio\Client; $accessKey = '12345678901234567890'; $secure = true; // Optional, default is true (only paid plans of fixer.io supports SSL) $config = []; // Optional, guzzle command client config that you might want to pass $fixerio = Client::create($accessKey, $secure, $config);
Here's how you can access the fixer.io's endpoints:
Note: access_key parameter is sent by default in all requests so no need to pass it in the argument while calling methods. However, you can include it should you want to override the access key used while instantiating the fixerio client.
Latest rates endpoint
$latestRates = $fixerio->latest( [ 'base' => 'USD', // optional 'symbols' => 'INR', // optional ] ); // Display the INR rates echo $latestRates['rates']['INR'];
Historical rates endpoint
$historicalRates = $fixerio->historical( [ 'date' => '2019-01-01', 'base' => 'USD', // optional 'symbols' => 'INR', //optional ] ); // Display the INR rates echo $latestRates['rates']['INR'];
Convert endpoint
$convertedRates = $fixerio->convert( [ 'from' => 'USD', 'to' => 'INR', 'amount' => 50.75, 'date' => '2019-01-01', //optional ] ); // Display the converted amount echo $convertedRates['result'];
Time-Series data endpoint
$timeseriesData = $fixerio->timeseries( [ 'start_date' => '2019-01-01', 'end_date' => '2019-01-05', 'base' => 'USD', // optional 'symbols' => 'INR', //optional ] ); // Display the INR rate for 2019-01-02 echo $timeseriesData['rates']['2019-01-02']['INR'];
Fluctuation data endpoint
$fluctuationData = $fixerio->fluctuation( [ 'start_date' => '2019-01-01', 'end_date' => '2019-01-05', 'base' => 'USD', // optional 'symbols' => 'INR', //optional ] ); // Display the change/fluctuation amount of INR between the given date range echo $fluctuationData['rates']['INR']['change'];
The response for all the above calls will be a JSON object. Please refer fixer.io's documentation for further details about various endpoints, request parameters and response objects.
License
This package is open-sourced software licensed under the MIT license.
ranium/fixerio-php-client 适用场景与选型建议
ranium/fixerio-php-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45.57k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 02 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ranium/fixerio-php-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ranium/fixerio-php-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 45.57k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 32
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-02-05