Bitcoin Forum
December 15, 2024, 01:03:42 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitfenix API authentication  (Read 10328 times)
gigamike (OP)
Member
**
Offline Offline

Activity: 90
Merit: 10


View Profile
March 24, 2014, 08:00:04 AM
Last edit: March 24, 2014, 11:18:59 PM by gigamike
 #1

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.

Code:
<?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($curlCURLOPT_HTTPHEADER$headers);      
curl_setopt ($curlCURLOPT_URL$apiUrl);
curl_setopt($curlCURLOPT_FOLLOWLOCATION1);
curl_setopt($curlCURLOPT_RETURNTRANSFER1);
$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
gigamike (OP)
Member
**
Offline Offline

Activity: 90
Merit: 10


View Profile
March 24, 2014, 11:18:36 PM
 #2

Hi,

ok i was able to figure out

Code:
<?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($curlCURLOPT_POSTFIELDS'');
curl_setopt($curlCURLOPT_POST0);
curl_setopt($curlCURLOPT_HTTPHEADER$headers);      
curl_setopt ($curlCURLOPT_URL$apiUrl);
curl_setopt($curlCURLOPT_FOLLOWLOCATION1);
curl_setopt($curlCURLOPT_RETURNTRANSFER1);
$curlResult curl_exec ($curl);
curl_close($curl);

echo 
$curlResult;

solved.

Thanks,

Mike
mattmcegg
Newbie
*
Offline Offline

Activity: 27
Merit: 0


View Profile
May 31, 2014, 12:24:17 AM
 #3

Hi,

ok i was able to figure out

Code:
<?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($curlCURLOPT_POSTFIELDS'');
curl_setopt($curlCURLOPT_POST0);
curl_setopt($curlCURLOPT_HTTPHEADER$headers);      
curl_setopt ($curlCURLOPT_URL$apiUrl);
curl_setopt($curlCURLOPT_FOLLOWLOCATION1);
curl_setopt($curlCURLOPT_RETURNTRANSFER1);
$curlResult curl_exec ($curl);
curl_close($curl);

echo 
$curlResult;

solved.

Thanks,

Mike

What is the fix? I am still getting the same error.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!