Created
November 15, 2017 11:31
-
-
Save phpfiddle/f9a228863b42de54512f3a63a76282ca to your computer and use it in GitHub Desktop.
[ Posted by Misha.vakulich@gmail.com ] Signature calculation example PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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