Created
June 30, 2011 12:21
-
-
Save shevron/1056123 to your computer and use it in GitHub Desktop.
Creating a Zend Server Web API request signature using 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 | |
/** | |
* Calculate Zend Server Web API request signature | |
* | |
* @param string $host Exact value of the 'Host:' HTTP header | |
* @param string $path Request URI | |
* @param integer $timestamp Timestamp used for the 'Date:' HTTP header | |
* @param string $userAgent Exact value of the 'User-Agent:' HTTP header | |
* @param string $apiKey Zend Server API key | |
* @return string Calculated request signature | |
*/ | |
function generateRequestSignature($host, $path, $timestamp, $userAgent, $apiKey) | |
{ | |
$data = $host . ":" . | |
$path . ":" . | |
$userAgent . ":" . | |
gmdate('D, d M y H:i:s ', $timestamp) . 'GMT'; | |
return hash_hmac('sha256', $data, $apiKey); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment