How to create a signature for the Ascentis API using PHP -
i trying create proper signature ascentis api. there documentation http://www.ascentis.com/api/ascentis_api_documentation.pdf. page 4 describes signature format.
here php code. doing wrong? "not authorized error".
$url='https://selfservice2.ascentis.com/mycompany/api/v1.1/employees'; $timestamp=gmdate('y-m-d\th:i:s\z'); $path=strtolower(str_replace('https://selfservice2.ascentis.com','',$url)); $signature_string="get {$path} {$timestamp}"; $signature=hash_hmac("sha1",$signature_string,$secret_key); $authorization=encodeurl($client_key).':'.encodeurl($signature);
after playing trial , error game able working. turns out have set hash_hmac raw_output. here working code:
$url='https://selfservice2.ascentis.com/mycompany/api/v1.1/employees'; $timestamp=gmdate('y-m-d\th:i:s\z'); $path=strtolower(str_replace('https://selfservice2.ascentis.com','',$url)); $signature_string="get {$path} {$timestamp}"; $signature=base64_encode(hash_hmac("sha1",$signature_string,$codes['secret_key'],true)); $authorization=encodeurl($client_key).':'.encodeurl($signature);
Comments
Post a Comment