Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martijngastkemper/083c4f4ed14c2c57e2ff262f60845954 to your computer and use it in GitHub Desktop.
Save martijngastkemper/083c4f4ed14c2c57e2ff262f60845954 to your computer and use it in GitHub Desktop.
A script to create an authorization string to connect with the Buckaroo JSON API.
<?php
$websiteKey = 'website-key';
$secretToken = 'secret-token';
$nonce = 'a-random-alphanumeric-string';
$requestBody = "{json: 'request'}";
$time = (string)time();
$parts = [
$websiteKey,
strtoupper('post or get'),
strtolower(urlencode('you-website.com/path/to/destination')),
$time,
$nonce,
$requestBody
? base64_encode(md5($requestBody, true))
: ''
];
$authorization = 'hmac ' . $websiteKey;
$authorization .= ':' . base64_encode(hash_hmac('sha256', implode('', $parts), $secretToken, true));
$authorization .= ':' . $nonce;
$authorization .= ':' . $time;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment