gabrielandy / coindesk
Laravel 的 CoinDesk 比特币价格指数 API
v1.2.0
2021-06-10 20:44 UTC
Requires
- php: ^7.3 || ^8.0
- guzzlehttp/guzzle: ^7.0.1
- illuminate/support: ^8.40
Requires (Dev)
- orchestra/testbench: ^5.0 || ^6.0
- phpunit/phpunit: ^9.0
README
在 Laravel 应用程序中实现 CoinDesk 比特币价格指数 (BPI)
此软件包允许您在 Laravel 应用程序中查询支持的 CoinDesk 官方货币的比特币汇率。
要求
- PHP >= 7.4
- Laravel >= 7.0
- Guzzle 7.0
安装
您可以通过 composer 安装此软件包
composer require gabrielandy/coindesk
用法
获取任何支持货币的比特币价值
use Coindesk; /** * Convert from Bitcoin to Coindesk's supported fiat currency (USD, GBP, EUR, NGN, GHC). * * @example Coindesk::toFiatCurrency('USD', 1) * * @param string $currency_code - The ISO 4217 fiat currency you wish to convert Bitcoin to * @param int $bitcoin_amount - The value of Bitcoin in float/numeric * @return float */ Coindesk::toFiatCurrency($currency_code, $bitcoin_amount); Coindesk::toFiatCurrency('USD', 1); // This will return 36579.71 stating that ₿1 = $36,579.71 Coindesk::toFiatCurrency('EUR', 1); // This will return 29951.01 stating that ₿1 = €29,951.01 Coindesk::toFiatCurrency('NGN', 1); // This will return 15028918.04 stating that ₿1 = ₦15,028,918.04
将任何支持的货币价值转换为比特币
use Coindesk; /** * Convert any supported Coindesk's fiat currency to Bitcoin. * * @example Coindesk::toBtc(1, 'USD') * * @param int $amount - The amount of the currency in integer/numeric * @param string $currency = USD - The currency you wish to convert to Bitcoin * @return string */ Coindesk::toBtc($amount, $currency_code); Coindesk::toBtc(1, 'USD'); // This will return 0.000027 stating that $1 = ₿0.000027 Coindesk::toBtc(1, 'EUR'); // This will return 0.000034 stating that €1 = ₿0.000034 Coindesk::toBtc(1, 'NGN'); // This will return 0.000000067 stating that ₦1 = ₿0.000000067
变更日志
请参阅 CHANGELOG 了解最近更改的详细信息。
贡献
请访问 贡献 页面以获取详细信息。
安全
如果您发现任何安全相关的问题,请发送电子邮件至 master@andikangabriel.com,而不是使用问题跟踪器。
许可证
MIT 许可证。请参阅 许可证 文件以获取详细信息。
免责声明
此项目与 CoinDesk 无任何关联。它旨在提供有用服务,不提供任何保证或责任。作者不对使用 API 期间发生的任何损害或问题负责。
您有权根据需要使用此软件包来使用 CoinDesk 的 API,但每个使用它的页面或应用程序都必须包含文本 "由 CoinDesk 提供",链接到 CoinDesk 的 定价页面。