title: Bitfinex API v2 Authenticated Endpoints using PHP and cURL
body: <p>I am sure I am so close, but just off. I am trying to return my wallet balances with the Bitfinex v2 API, but I keep getting the "invalid key" error.</p>
  
  <p>After having a look at <a href="https://stackoverflow.com/questions/44830995/bitfinex-api-v2-error-invalid-key">this question</a> I think my issue might be related, but updating my code with <code>utf8_encode</code> didn't fix the issue.</p>
  
  <p>This is my first time using cURL, so I'm not very confident that I have set all of the options correctly.</p>
  
  <p>Thanks in advance for any help that's offered.</p>
  
  <p>My code so far (you'll have to trust that <code>_APISECRET</code> and <code>_APIKEY</code> are set):</p>
  
  <pre><code>CONST _APIPATH = "v2/auth/r/wallets";
  CONST _APIURL = "https://api.bitfinex.com/";
  
  $nonce = strval(time()*1000);
  $body = json_encode(array());
  $signature = '/api/' . _APIPATH . $nonce . $body;
  
  $signature = hash_hmac('sha384', $signature, utf8_encode(_APISECRET));
  
  $headers = array('bfx-nonce' =&gt; $nonce, 'bfx-apikey' =&gt; utf8_encode(_APIKEY), 'bfx-signature' =&gt; $signature, 'content-type' =&gt; 'application/json');
  
  $ch = curl_init();
  
  curl_setopt($ch, CURLOPT_POST, TRUE);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
  curl_setopt($ch, CURLOPT_URL, _APIURL . _APIPATH);
  curl_setopt($ch, CURLOPT_HEADER, TRUE);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  
  curl_exec($ch);
  
  curl_close($ch);
  </code></pre>