Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created November 15, 2017 11:31
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 phpfiddle/f9a228863b42de54512f3a63a76282ca to your computer and use it in GitHub Desktop.
Save phpfiddle/f9a228863b42de54512f3a63a76282ca to your computer and use it in GitHub Desktop.
[ Posted by Misha.vakulich@gmail.com ] Signature calculation example PHP
<?php
$secret = 'onveilig gedeeld geheim';
$timeout = time() + 60*60; //1h signature expire, timeout in seconds
$parameters = array( //parameters example
'timeout' => $timeout,
'Sat' => '',
'a' => '1 vet',
'b' => '2 gaaf'
);
ksort($parameters);
$signature_str = '';
foreach ($parameters as $key => $val) {
$signature_str .= urlencode($key) . '=' . urlencode($val) . '&';
}
$signature_str = substr($signature_str, 0, -1);
$signature = 's1'.base64_encode(hash_hmac('sha1',$signature_str, $secret, true));
echo $signature. "<br/>";
echo "ResultUrl: \"https://domain/org/publication?" . $signature_str . "&Signature=" . urlencode($signature);
//prepare GET request with same parameters + Signature=$signature
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment