PHP code example of pepijnolivier / hitbtc-php-sdk
1. Go to this page and download the library: Download pepijnolivier/hitbtc-php-sdk 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/ */
pepijnolivier / hitbtc-php-sdk example snippets
$client = new \Hitbtc\ProtectedClient('API key', 'API secret', $demo = false);
$newOrder = new \Hitbtc\Model\NewOrder();
$newOrder->setSide($newOrder::SIDE_SELL);
$newOrder->setSymbol('BTCUSD');
$newOrder->setTimeInForce($newOrder::TIME_IN_FORCE_GTC);
$newOrder->setType($newOrder::TYPE_LIMIT);
$newOrder->setQuantity(10);
$newOrder->setPrice(800);
try {
$order = $client->newOrder($newOrder);
var_dump($order->getOrderId());
var_dump($order->getStatus()); // new
} catch (\Hitbtc\Exception\RejectException $e) {
echo $e; // if creating order will rejected
} catch (\Hitbtc\Exception\InvalidRequestException $e) {
echo $e->getMessage(); // error in request
} catch (\Exception $e) {
echo $e->getMessage(); // other error like network issue
}
try {
$order = $client->cancelOrder($order);
var_dump($order->getStatus()); // canceled
} catch (\Hitbtc\Exception\RejectException $e) {
echo $e; // if creating order will rejected
} catch (\Hitbtc\Exception\InvalidRequestException $e) {
echo $e->getMessage(); // error in request
} catch (\Exception $e) {
echo $e->getMessage(); // other error like network issue
}