PHP code example of volabit / client

1. Go to this page and download the library: Download volabit/client 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/ */

    

volabit / client example snippets




use Volabit\Client\OAuth2Client as VolabitClient;

$app_id   = 'The registered API for your APP.';
$secret   = 'The registered secret for your APP.';
$callback = 'The registered callback URL for your APP';

$volabitClient = new VolabitClient($app_id, $secret, $callback);

$volabitClient->sandbox(true);

$auth_url = $volabitClient->authorize();

$volabitClient->getTokens('The given authorization code.');

$tokens = [
  'access_token' => 'an access token',
  'refresh_token' => 'a refresh token',
  'expires_in' => 'expiration time (unix time format)'
];

$volabitClient->useTokens($tokens);

$response = $volabitClient->tickers();
print_r($response);
// Array
// (
//    [btc_usd_buy] => 236.42
//    [btc_usd_sell] => 236.51
//    [usd_mxn_buy] => 14.59
//    [usd_mxn_sell] => 15.19
//    [btc_mxn_buy] => 3450.44
//    [btc_mxn_sell] => 3592.64
// )