khاندurdyiev / monobank-php-client

Monobank API 的 PHP 客户端

v1.0.5 2021-04-11 18:02 UTC

This package is auto-updated.

Last update: 2024-09-07 23:24:18 UTC


README

Total Downloads Latest Stable Version License PHP Version

Monobank php 客户端可以帮助您轻松使用 Monobank API

安装

建议您使用 Composer 安装 Monobank php 客户端。

$ composer require khandurdyiev/monobank-php-client

重要

所有金额以分(根据 Monobank API)计算

基本使用(公开数据)

<?php

use Khandurdyiev\MonoClient\MonoClient;

// create a monobank client instance
$mono = new MonoClient();
$currencies = $mono->currency()->all();

foreach ($currencies as $currency) {
    $currencyA = $currency->getCurrencyA(); // USD
    $currencyB = $currency->getCurrencyB(); // UAH
    $date = $currency->getDate(); // returns Carbon instance with date
    // ...
}

使用令牌(私有数据)

<?php

use Carbon\Carbon;
use Khandurdyiev\MonoClient\MonoClient;

// create a monobank client instance
$mono = new MonoClient('your_monobank_api_token'); // you can get from https://api.monobank.ua

// Get client info
$clientInfo = $mono->clientInfo();
$name = $clientInfo->getName();
$accounts = $clientInfo->getAccounts()->all();

foreach ($accounts as $account) {
    $balance = $account->getBalance(); // 123456
    $creditLimit = $account->getCreditLimit(); // 654321
    $currency = $account->getCurrency(); // UAH
    
    // ...
}

// Get statements of concrete account
$from = Carbon::now()->subMonth();
$to = Carbon::now();
$statements = $mono->statements($from, $to, 'account_id')->all();

foreach ($statements as $statement) {
    $amount = $statement->getAmount(); // 123456
    $cashbackAmount = $statement->getCashbackAmount(); // 123456
    $currency = $statement->getCurrency(); // UAH
    // ...
}

许可证

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