Author

Topic: Bitfenix API authentication (Read 10328 times)

newbie
Activity: 27
Merit: 0
May 30, 2014, 07:24:17 PM
#3
member
Activity: 90
Merit: 10
March 24, 2014, 06:18:36 PM
#2
Hi,

ok i was able to figure out

Code:
$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
member
Activity: 90
Merit: 10
March 24, 2014, 03:00:04 AM
#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:
$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
Jump to: