- var_dump: documentation ( source)
- hash_hmac: documentation ( source)
- rawurlencode: documentation ( source)
- base64_encode: documentation ( source)
- strtotime: documentation ( source)
- sprintf: documentation ( source)
<?php
function calculate_signature($string, $private_key) {
$hash = hash_hmac("sha1", $string, $private_key, true);
$sig = rawurlencode(base64_encode($hash));
return $sig;
}
$api_key = "1234";
$private_key = "abcd";
$method = "GET";
$route = "forms";
$expires = strtotime("7:00");
$string_to_sign = sprintf("%s:%s:%s:%s", $api_key, $method, $route, $expires);
$sig = calculate_signature($string_to_sign, $private_key);
var_dump($sig);
var_dump(strtotime("7:00"));
?>