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
https://forums.phpfreaks.com/topic/295563-post-using-curl-to-bitcoin-exchange/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.