Skip to content

Instantly share code, notes, and snippets.

@shevron
Created June 30, 2011 12:21
Show Gist options
  • Save shevron/1056123 to your computer and use it in GitHub Desktop.
Save shevron/1056123 to your computer and use it in GitHub Desktop.
Creating a Zend Server Web API request signature using PHP
<?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