Jump to content

POST using cURL to Bitcoin Exchange


peterhuynh

Recommended Posts

Hello world,

 

I'm trying to submit an order at a bitcoin exchange. This is their example:

$nonce = time();
$token = 'xoxoxoxoxoxoxoxox';
$secret = ‘qwertyuioplkjhgfdsa’;
$path = '/api2/user/order.json';

$params = array( 'amount' => '0.1', 'mode' => 'buy', 'price' => '965.45' );

//param values must be appended in alphabetical order by key to the message
$message = “{$nonce}{$token}{$path}0.1buy965.45”;

$signature = hash_hmac(‘sha256’, $message, $secret); 

And I use cURL to post that stuff:

$ch = curl_init('https://www.cavirtex.com/api2/user/order.json');
curl_setopt($ch, CURLOPT_HTTPHEADER, $signature);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($message));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);

It doesn't work. I get this:

{"status": "error", "message": "No token key in requests"}

Help?

Please?

Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.