Post
Topic
Board Service Discussion
Topic OP
Bitfenix API authentication
by
gigamike
on 24/03/2014, 08:00:04 UTC
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