For anyone that is interested, I worked out how to do this (for Mac users at least).
The challenge was to pass an api key, timestamp and hash based on this PHP code
$hash = hash_hmac(‘sha1’, $api_key . $timestamp, $api_secret)
to produce a request like this: https:// [companyname].com/api/v1/sessions/current?api_key=api_key×tamp=current_ts&hash=your_hash
The solution is this.
Use the bash node.
Set the command as this: php -f Hashmac.php >test.log 2>&1
Set your execution directory to…well that should be obvious.
Hashmac.php is the file with the script in it, in the execution directory. Test.log is not needed for the workflow, as far as I can tell, but I don’t understand the code so just left it in.
The script in Hashmac.php is:
<?php
$api_key = "your key";
$api_secret = "your secret key";
list($msec, $sec) = explode(' ', microtime());
// these parentheses are mandatory otherwise the precedence is wrong!
// ↓ ↓
$timestamp = (int) ($sec.substr($msec, 2, 3));
$hash = hash_hmac('sha1', $api_key . $timestamp, $api_secret);
echo $hash.PHP_EOL;
echo $timestamp.PHP_EOL
?>
Seems to work.
The code isn’t mine - I don’t code and don’t understand it - I got most of it from here: https://stackoverflow.com/questions/3656713/how-to-get-current-time-in-milliseconds-in-php.
This would probably take someone who understands this stuff minutes, but it took me hours, so thought I’d share it for anyone else like me.
R.