Switching from curl implementation to using laravel Http facade to access poloniex
private api.
But I am having issues with it. I get an invalid command response from poloniex, yet all my parameters seem to work alright.
Sample code below, this is the case with all endpoints but we'll use the returnBalances command to test this here:
$req = ['command' => 'returnBalances'];
// generate a nonce
$time = explode(' ', microtime());
$req['nonce'] = $time[1].substr($time[0], 2, 6);
$parameters = http_build_query($req, '', '&');
$sign = hash_hmac('sha512', $parameters, $my_secret);
$response = Http::withHeaders(["key" => $my_key, 'Sign' '=> $my_secret])
->post('https://poloniex.com/tradingApi', $req);
The above response json returns:
array:1 [
"error" => "Invalid command."
].
My code works fine though when working directly with curl, seems like the http facade is not sending request parameters