PHP code example of seegno / bitreserve-sdk-php

1. Go to this page and download the library: Download seegno/bitreserve-sdk-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

seegno / bitreserve-sdk-php example snippets






use Uphold\UpholdClient as Client;

// Initialize the client.
$client = new Client(array(
  'client_id' => 'APPLICATION_CLIENT_ID',
  'client_secret' => 'APPLICATION_CLIENT_SECRET',
));

// Authorize user using the code parameter from the application redirect url.
$user = $client->authorizeUser('CODE');

// Get the Bearer token.
$bearer = $user->getClient()->getOption('bearer');



use Uphold\UpholdClient as Client;

// Initialize the client.
$client = new Client();

// Get user.
$user = $client->getUser('AUTHORIZATION_TOKEN');



use Uphold\UpholdClient as Client;

// Initialize the client.
$client = new Client();

// Get user.
$user = $client->getUser('AUTHORIZATION_TOKEN');

// Get user balances for all currencies.
$balances = $user->getBalances();

// Get user total balance.
$balance = $user->getTotalBalance();

Array
(
    [amount] => 3.14
    [currency] => BTC
)



use Uphold\UpholdClient as Client;

// Initialize the client.
$client = new Client();

// Get user.
$user = $client->getUser('AUTHORIZATION_TOKEN');

// Get current user cards.
$cards = $user->getCards();



use Uphold\UpholdClient as Client;

// Initialize the client.
$client = new Client();

// Get the current user.
$user = $client->getUser('AUTHORIZATION_TOKEN');

// Create a new 'BTC' card.
$card = $user->createCard('My new card', 'BTC');

Uphold\Model\Card Object
(
    [id:protected] => ade869d8-7913-4f67-bb4d-72719f0a2be0
    [address:protected] => Array
        (
            [bitcoin] => 1GpBtJXXa1NdG94cYPGZTc3DfRY2P7EwzH
        )

    [addresses:protected] => Array
        (
            [0] => Array
                (
                    [id] => 1GpBtJXXa1NdG94cYPGZTc3DfRY2P7EwzH
                    [network] => bitcoin
                )

        )

    [available:protected] => 0.00
    [balance:protected] => 0.00
    [currency:protected] => BTC
    [label:protected] => My new card
    [lastTransactionAt:protected] =>
    [transactions:protected] =>
    [settings] => Array
        (
            [position] => 10
        )
)



use Uphold\UpholdClient as Client;

// Initialize the client.
$client = new Client();

// Get rates (public endpoint).
$rates = $client->getRates();

// Get rates for BTC.
$rates = $client->getRatesByCurrency('BTC');

Array
(
    [0] => Uphold\Model\Rate Object
        (
            [ask:protected] => 1
            [bid:protected] => 1
            [currency:protected] => BTC
            [pair:protected] => BTCBTC
        )

    [1] => Uphold\Model\Rate Object
        (
            [ask:protected] => 234.89
            [bid:protected] => 234.8
            [currency:protected] => USD
            [pair:protected] => BTCUSD
        )
)



use Uphold\UpholdClient as Client;

// Initialize the client.
$client = new Client();

// Get user.
$user = $client->getUser('AUTHORIZATION_TOKEN');

// Get a specific card by id.
$card = $user->getCardById('ade869d8-7913-4f67-bb4d-72719f0a2be0');

// Create a new transaction.
$transaction = $card->createTransaction('[email protected]', '2.0', 'BTC');

// Commit the transaction.
$transaction->commit();

Uphold\Model\Transaction Object
(
    [id:protected] => a97bb994-6e24-4a89-b653-e0a6d0bcf634
    [createdAt:protected] => 2015-01-30T11:46:11.439Z
    [denomination:protected] => Array
        (
            [pair] => BTCBTC
            [rate] => 1
            [amount] => 2.0
            [currency] => BTC
        )
    [destination:protected] => <snip>
    [message:protected] =>
    [origin:protected] => <snip>
    [params:protected] => <snip>
    [refundedById:protected] =>
    [status:protected] => completed
    [type] => transfer
)



use \Uphold\UpholdClient as Client;

// Initialize the client.
$client = new Client();

// Get all public transactions (public endpoint).
$pager = $client->getReserve()->getTransactions();

// Get next page of transactions.
$transactions = $pager->getNext();

// Get one public transaction.
$transaction = $client->getReserve()->getTransactionById('a97bb994-6e24-4a89-b653-e0a6d0bcf634');



use \Uphold\UpholdClient as Client;

// Initialize the client.
$client = new Client();

// Get the reserve summary of all the obligations and assets within it (public endpoint).
$statistics = $client->getReserve()->getStatistics();

// Get public transactions.
$pager = $client->getReserve()->getTransactions();

// Check whether the paginator has a valid next page.
while($pager->hasNext()) {
    // Get next page with results.
    $transactions = $pager->getNext();

    // Do something...
}
json
{
    "eegno/uphold-sdk-php": "~5.0"
    }
}