Title: Bitfenix API authentication
Post by: gigamike on March 24, 2014, 08:00:04 AM
Guys, Any idea what im missing. Im using https://www.bitfinex.com/pages/api. unfortunately there authentication doesnt have any sample. I tried google but not too much .php example. <?php $apiUrl = 'https://api.bitfinex.com/v1/margin_infos'; $keyId = 'xxxx'; $keySecret = 'xxxxxx';
$payload = array( 'request' => '/v1/margin_infos', 'nonce' => time() * 100000, ); $payload = base64_encode(json_encode($payload)); $signature = hash_hmac('sha384', $payload, $keySecret); $headers = array( "X-BFX-APIKEY : " . $keyId, "X-BFX-PAYLOAD : " . $payload, "X-BFX-SIGNATURE : " . $signature, ); $curl = curl_init(); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt ($curl, CURLOPT_URL, $apiUrl); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $curlResult = curl_exec ($curl); curl_close($curl);
echo $curlResult;
Result/Error {"message":"Could not find a key matching the given X-BFX-APIKEY."} But i did pass X-BFX-APIKEY as header TIA, Mike
Title: Re: Bitfenix API authentication
Post by: gigamike on March 24, 2014, 11:18:36 PM
Hi, ok i was able to figure out <?php $apiUrl = 'https://api.bitfinex.com/v1/margin_infos'; $apiKey = 'xxx'; $apiSecret = 'yyy';
$payload = array( 'request' => '/v1/margin_infos', 'nonce' => strval(time() * 100000), ); $payload = base64_encode(json_encode($payload)); $signature = hash_hmac('sha384', $payload, $apiSecret); $headers = array( "X-BFX-APIKEY : " . $apiKey, "X-BFX-PAYLOAD : " . $payload, "X-BFX-SIGNATURE : " . $signature, ); $curl = curl_init(); curl_setopt($curl, CURLOPT_POSTFIELDS, ''); curl_setopt($curl, CURLOPT_POST, 0); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt ($curl, CURLOPT_URL, $apiUrl); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $curlResult = curl_exec ($curl); curl_close($curl);
echo $curlResult;
solved. Thanks, Mike
Title: Re: Bitfenix API authentication
Post by: mattmcegg on May 31, 2014, 12:24:17 AM
Hi, ok i was able to figure out <?php $apiUrl = 'https://api.bitfinex.com/v1/margin_infos'; $apiKey = 'xxx'; $apiSecret = 'yyy';
$payload = array( 'request' => '/v1/margin_infos', 'nonce' => strval(time() * 100000), ); $payload = base64_encode(json_encode($payload)); $signature = hash_hmac('sha384', $payload, $apiSecret); $headers = array( "X-BFX-APIKEY : " . $apiKey, "X-BFX-PAYLOAD : " . $payload, "X-BFX-SIGNATURE : " . $signature, ); $curl = curl_init(); curl_setopt($curl, CURLOPT_POSTFIELDS, ''); curl_setopt($curl, CURLOPT_POST, 0); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt ($curl, CURLOPT_URL, $apiUrl); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $curlResult = curl_exec ($curl); curl_close($curl);
echo $curlResult;
solved. Thanks, Mike What is the fix? I am still getting the same error.
|