Bitmex API signature signing
up vote
0
down vote
favorite
I'm trying to make a post request to Bitmex API with JS and PHP.
Here's what I did:
Javascript:
var post_data = {"symbol" : symbol, "side": side, "simpleOrderQty" : qty, "ordType" : ordType};
var path = '/api/v1/order';
var expire = Math.round((new Date()).getTime() / 1000) + 10;
var message = "POST" + path+ expire.toString() + data;
var secret = CryptoJS.HmacSHA256(message, secret).toString(CryptoJS.enc.Hex); // this is the secret that I will use in my php code
//hash from this string: POST/api/v1/order1541770067{"symbol":"XBTUSD","side":"Buy","simpleOrderQty":5,"ordType":"Market"} which looks like their example
However when I use curl PHP if I set the post field to this:
{"symbol":"XBTUSD","side":"Buy","simpleOrderQty":5,"ordType":"Market"} // as a string
it gives me a "symbol" is a required parameter, which I assume if right because that string shouldn't work anyway.
but if I use
http_build_query(json_decode($that_string, true));
It will give signature error instead.
So how should I go with this to make it works?
For reference: https://www.bitmex.com/app/apiKeysUsage
php rest
add a comment |
up vote
0
down vote
favorite
I'm trying to make a post request to Bitmex API with JS and PHP.
Here's what I did:
Javascript:
var post_data = {"symbol" : symbol, "side": side, "simpleOrderQty" : qty, "ordType" : ordType};
var path = '/api/v1/order';
var expire = Math.round((new Date()).getTime() / 1000) + 10;
var message = "POST" + path+ expire.toString() + data;
var secret = CryptoJS.HmacSHA256(message, secret).toString(CryptoJS.enc.Hex); // this is the secret that I will use in my php code
//hash from this string: POST/api/v1/order1541770067{"symbol":"XBTUSD","side":"Buy","simpleOrderQty":5,"ordType":"Market"} which looks like their example
However when I use curl PHP if I set the post field to this:
{"symbol":"XBTUSD","side":"Buy","simpleOrderQty":5,"ordType":"Market"} // as a string
it gives me a "symbol" is a required parameter, which I assume if right because that string shouldn't work anyway.
but if I use
http_build_query(json_decode($that_string, true));
It will give signature error instead.
So how should I go with this to make it works?
For reference: https://www.bitmex.com/app/apiKeysUsage
php rest
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm trying to make a post request to Bitmex API with JS and PHP.
Here's what I did:
Javascript:
var post_data = {"symbol" : symbol, "side": side, "simpleOrderQty" : qty, "ordType" : ordType};
var path = '/api/v1/order';
var expire = Math.round((new Date()).getTime() / 1000) + 10;
var message = "POST" + path+ expire.toString() + data;
var secret = CryptoJS.HmacSHA256(message, secret).toString(CryptoJS.enc.Hex); // this is the secret that I will use in my php code
//hash from this string: POST/api/v1/order1541770067{"symbol":"XBTUSD","side":"Buy","simpleOrderQty":5,"ordType":"Market"} which looks like their example
However when I use curl PHP if I set the post field to this:
{"symbol":"XBTUSD","side":"Buy","simpleOrderQty":5,"ordType":"Market"} // as a string
it gives me a "symbol" is a required parameter, which I assume if right because that string shouldn't work anyway.
but if I use
http_build_query(json_decode($that_string, true));
It will give signature error instead.
So how should I go with this to make it works?
For reference: https://www.bitmex.com/app/apiKeysUsage
php rest
I'm trying to make a post request to Bitmex API with JS and PHP.
Here's what I did:
Javascript:
var post_data = {"symbol" : symbol, "side": side, "simpleOrderQty" : qty, "ordType" : ordType};
var path = '/api/v1/order';
var expire = Math.round((new Date()).getTime() / 1000) + 10;
var message = "POST" + path+ expire.toString() + data;
var secret = CryptoJS.HmacSHA256(message, secret).toString(CryptoJS.enc.Hex); // this is the secret that I will use in my php code
//hash from this string: POST/api/v1/order1541770067{"symbol":"XBTUSD","side":"Buy","simpleOrderQty":5,"ordType":"Market"} which looks like their example
However when I use curl PHP if I set the post field to this:
{"symbol":"XBTUSD","side":"Buy","simpleOrderQty":5,"ordType":"Market"} // as a string
it gives me a "symbol" is a required parameter, which I assume if right because that string shouldn't work anyway.
but if I use
http_build_query(json_decode($that_string, true));
It will give signature error instead.
So how should I go with this to make it works?
For reference: https://www.bitmex.com/app/apiKeysUsage
php rest
php rest
asked Nov 9 at 13:37
Lê Hồng Nhật
11
11
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53226763%2fbitmex-api-signature-signing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown