@ 2015-11-20T08:56:34Z <?php
class Bitfinex {
private $api_key;
private $api_secret;
private $api_version;
private $base_url = 'https://api.bitfinex.com';
public function __construct($api_key, $api_secret, $api_version = 'v1')
{
$this->api_key = $api_key;
$this->api_secret = $api_secret;
$this->api_version = $api_version;
}
public function get_balances()
{
$request = '/' . $this->api_version . '/balances';
echo $request;
$data = array(
'request' => $request,
'options' => array()
);
return $this->send_signed_request($data);
}
private function prepare_header($data)
{
$data['nonce'] = 144800329405116;
//(string) number_format(round(microtime(true) * 100000),0,'.','');
echo $data;
echo '<br/>';
echo "Json encode";
echo '<br/>';
echo json_encode($data);
echo '<br/>';
$payload = base64_encode(json_encode($data));
$signature = hash_hmac('sha384', $payload, $this->api_secret);
echo "payload ";
echo $payload;
echo " sig ";
echo $signature;
echo " ";
return array(
'X-BFX-APIKEY: ' . $this->api_key,
'X-BFX-PAYLOAD: ' . $payload,
'X-BFX-SIGNATURE: ' . $signature
);
}
private function send_signed_request($data)
{
$ch = curl_init();
$url = $this->base_url . $data['request'];
// echo $url;
$headers = $this->prepare_header($data);
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_POSTFIELDS => ""
));
// $information = curl_getinfo($ch);
echo $information;
// echo $result;
if( !$result = curl_exec($ch) )
{
trigger_error(curl_error($ch));
echo "NO <br/>";
echo $result;
return false;
}
else
{
echo "YES <br/>";
return json_decode($result, true);
}
}
}
$la = new Bitfinex('85FOKLshSVnZxRLtCoTFw2qHDIQf5TCEOWj9nk6CRBQ', 'E8AeyGATKUFmWLSWLGSYznRFmaoboxgGPzmRzgn0G8x', 'v1');
$drek = $la->get_balances();
//$information = curl_getinfo($curl_exect);
echo '<br/>';
echo 'Recived data';
echo $drek;
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.20 , 7.1.0 - 7.1.25 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 /v1/balances
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/WD8n9:60
Stack trace:
#0 /in/WD8n9(27): Bitfinex->send_signed_request(Array)
#1 /in/WD8n9(99): Bitfinex->get_balances()
#2 {main}
thrown in /in/WD8n9 on line 60
Process exited with code 255 . Output for 5.5.0 - 5.5.38 , 5.6.0 - 5.6.28 /v1/balances
Fatal error: Call to undefined function curl_init() in /in/WD8n9 on line 60
Process exited with code 255 . preferences:dark mode live preview
185.45 ms | 402 KiB | 238 Q