baffouradu/currency-convertor

一个用于 currencyconverterapi.com 的 PHP 库。

1.0.0 2019-03-10 23:21 UTC

This package is auto-updated.

Last update: 2024-09-14 10:57:56 UTC


README

一个 PHP 库,用于 https://free.currencyconverterapi.com/,允许您:

  • 将一种货币的金额转换为另一种货币
  • 获取两种货币之间的汇率

关于货币转换API的更多信息

Free Currency Converter API始于2014年,现在是2019年,我们一直在运营。它为开发人员提供免费的网络服务,以将一种货币转换为另一种货币。您可以自由用于个人或商业应用,但我们不提供任何保证。货币价值每60分钟更新一次。

安装

使用composer安装此包。

composer require baffouradu/currency-convertor

使用方法

<?php

use BaffourAdu\CurrencyConvertor\Convertor;

require 'vendor/autoload.php';

//Insert your free api key generatored from https://free.currencyconverterapi.com/free-api-key
$currencyConvertor = new Convertor('xxxxxxxxxxxxxxxxxxxxxx');

/**
 * Get the exchange rate between two currencies
*/
echo $currencyConvertor->from('CAD')
                    ->to('GHS')
                    ->getRate();

/**
 * Convert an amount from one currency to another
*/
echo $res = $currencyConvertor->from('CAD')
                    ->to('GHS')
                    ->amount(150.00)
                    ->convert();

贡献

欢迎Pull请求。对于主要更改,请首先打开一个问题来讨论您想要更改的内容。

请确保根据需要更新测试。

许可

MIT