@ 2015-11-20T09:02:16Z <?php
class Bitfinex {
private $api_key;
private $api_secret;
private $api_version;
private $base_url = 'https://192.230.80.104';
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) )
{
echo "Error";
echo curl_error($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 git.master , git.master_jit , rfc.property-hooks /v1/balances
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/pZ4X2:60
Stack trace:
#0 /in/pZ4X2(27): Bitfinex->send_signed_request(Array)
#1 /in/pZ4X2(102): Bitfinex->get_balances()
#2 {main}
thrown in /in/pZ4X2 on line 60
Process exited with code 255 . This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.
Active branches Archived branches Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page
preferences:dark mode live preview
53.02 ms | 401 KiB | 8 Q