PHP code example of matmar10 / campbx

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

    

matmar10 / campbx example snippets

 composer.phar update






use Matmar10\CampBX\CampBXClient;

$client = CampBXClient::factory();



use Matmar10\CampBX\CampBXAuthClient;

$client = CampBXAuthClient::factory(array(
    'username' => 'your username',
    'password' => 'your password'
));



$command = $client->getCommand('GetTicker');
$response = $client->execute($command);

// returns an instance of Matmar10\Money\Entity\CurrencyPair
$askPrice = $response->get('ask');



$command = $client->getCommand('GetMarketDepth');
$response = $client->execute($command);

foreach($response->get('ask') as $marketDepthPrice) {
    echo $marketDepthPrice->getPrice()->getamountDisplay() . ": ";
    echo $marketDepthPrice->getAmount()->getamountDisplay() . "\n";
}



$command = $client->getCommand('GetTicker');
$response = $client->execute($command);

echo "BUY: " . $response->get('bid')->getMultiplier() . "\n";
echo "SELL: " . $response->get('ask')->getMultiplier() . "\n";



$client = CampBXAuthClient::factory(array(
    'username' => 'your-campbx-username',
    'password' => 'changeme',
));

$command = $client->getCommand('GetAccountBalances');
$response = $client->execute($command);
echo "Total BTC: " . $response->get('totalBTC')->getAmountFloat() . "\n";
echo "Total USD: " . $response->get('totalUSD')->getAmountFloat() . "\n";

examples/market-data/market-depth.php
examples/market-data/ticker.php
examples/account-data/balance.php