1

I'm trying to get my wallet balance with the bittrex API and i don't understand why the code provided by bittrex documentation doesn't work :

$apikey = 'xxx';
$apisecret = 'xxx';
$nonce = time();
$uri = 'https://bittrex.com/api/v1.1/market/getopenorders?apikey=' .
    $apikey . '&nonce=' . $nonce;
$sign = hash_hmac('sha512', $uri, $apisecret);
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:' . $sign));
$execResult = curl_exec($ch);
$obj = json_decode($execResult);

The curl_exec function returns false, i don't understand why. Thank for your help !

aristotll
  • 8,694
  • 6
  • 33
  • 53
Zenor27
  • 171
  • 1
  • 11

1 Answers1

0

Try to add further error handling, smthing like this

try {
    $ch = curl_init();

    if (FALSE === $ch)
        throw new Exception('failed to initialize');

    curl_setopt($ch, CURLOPT_URL, $uri);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    $execResult = curl_exec($ch);

    if (FALSE === $execResult)
        throw new Exception(curl_error($ch), curl_errno($ch));

} catch(Exception $e) {

    trigger_error(sprintf(
        'Curl failed with error #%d: %s',
        $e->getCode(), $e->getMessage()),
        E_USER_ERROR);

}
toffler
  • 1,231
  • 10
  • 27
  • I've got this error : Fatal error: Curl failed with error #60: SSL certificate problem: unable to get local issuer certificate – Zenor27 Aug 18 '17 at 09:23
  • [Look @ this question for further information about this error](https://stackoverflow.com/questions/24611640/curl-60-ssl-certificate-unable-to-get-local-issuer-certificate) – toffler Aug 18 '17 at 10:06
  • execute your code on live website or IP. As i have experienced this will not work in your local system. – Kishore Kumar Sep 01 '17 at 08:59