Bitso Api – Building the request

Bitso Say This

HTTP Request


Authorization Header Parameters

Parameter Default Required Description

key – Yes See Creating and Signing Requests

signature – Yes See Creating and Signing Requests

nonce – Yes See Creating and Signing Requests

Body Parameters

Body parameters should be JSON encoded and should be exactly the same as the JSON payload used to construct the signature.

Parameter Default Required Description

amount – Yes The amount of BTC to withdraw from your account

address – Yes The Bitcoin address to send the amount to

My Code Whats Wrong?

    $bitsoKey = "kayhere";
  $bitsoSecret = 'secrethere';
  $nonce = round(microtime(true) * 1000);
  $HTTPMethod = "POST";
  $RequestPath = "/v3/bitcoin_withdrawal/";
  $JSONPayload = "";

  // Create signature
  $message = $nonce . $HTTPMethod . $RequestPath . $JSONPayload;
  $signature = hash_hmac('sha256', $message, $bitsoSecret);

  // Build the auth header
$postData = array(
    'amount' => '0.12216614',
    'address' => '17bj3CkAByaKT8VZdi3zrRHpMJB1ktSHw3',


  $format = 'Bitso %s:%s:%s';
  $authHeader =  sprintf($format, $bitsoKey, $nonce, $signature);

  // Send request
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, '');
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
      'Authorization: '.$authHeader,
      'Content-Type: application/json'
  CURLOPT_POSTFIELDS => json_encode($postData);


  $result = curl_exec($ch);

if($result === FALSE){

// Decode the response
$responseData = json_decode($response, TRUE);

// Print the date from the response
echo $responseData['published'];


Source: stackoverflow-php