I'm trying to connect to an API and they only provide guides for python & Javascript. I'm trying to find the equivalent for php but coming up short.
For additional reference: https://docs.deribit.com/#authentication
I'm unable to get the proper signature in PHP.
Javascript:
var timestamp = Date.now(); var nonce = "abcd"; var data = ""; var signature = CryptoJS.HmacSHA256(`${timestamp}\n${nonce}\n${data}`, accessSecret).toString(); Python:
timestamp = round(datetime.now().timestamp() * 1000) nonce = "abcd" data = "" signature = hmac.new( bytes(clientSecret, "latin-1"), msg=bytes('{}\n{}\n{}'.format(timestamp, nonce, data), "latin-1"), digestmod=hashlib.sha256 ).hexdigest().lower() PHP: (*I don't know how to create the nonce)
$timestamp = number_format(microtime(true) * 1000, 0, '.', ''); $nonce = number_format(microtime(true) * 1000, 0, '.', ''); $data = ""; $key = $timestamp.$nonce.$data; $sign = hash_hmac('sha256',$key,$secret); $sign = bin2hex($sign);
$nonce = "abcd";abcdto what you want. (I will give you an example shortly)