Skip to content

Instantly share code, notes, and snippets.

@robmint
Created June 5, 2016 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robmint/1904c8b587078f68a8490896696130a6 to your computer and use it in GitHub Desktop.
Save robmint/1904c8b587078f68a8490896696130a6 to your computer and use it in GitHub Desktop.
Connect to the NZBCX bitcoin exchange via private API call
$key = ''; // fill in these details
$secret = '';
$id = '';
// Nonce of the current Unix timestamp string encoded
$nonce = strval(time());
$sigtext = $nonce . $id . $key;
$signature = hash_hmac ('sha256',$sigtext,$secret);
$prams = array(
'nonce' => $nonce,
'key' => $key,
'signature' => $signature
);
$url = 'https://nzbcx.com/api/account/balance';
$request = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($prams,'', '&'),
),
'ssl'=>array(
'allow_self_signed'=>true,
'verify_peer'=>false,
),
);
$context = stream_context_create($request);
$response = file_get_contents($url, false, $context);
var_dump($response);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment