Skip to content

Instantly share code, notes, and snippets.

@flukeout
Created November 19, 2009 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save flukeout/239108 to your computer and use it in GitHub Desktop.
Save flukeout/239108 to your computer and use it in GitHub Desktop.
Zeep Mobile - Authentication header - PHP
#!/usr/local/php5/bin/php -q
<?php
$API_KEY = "your_api_key";
$SECRET_ACCESS_KEY = "your_secret_key";
// you might think you could use the PHP const DATE_RFC1123 but it is defined as "D, d M Y H:i:s O"
$http_date = gmdate("D, d M Y H:i:s T");
// (ex. Sat, 12 Jul 2008 09:04:28 GMT)
$parameters = "user_id=1234&body=" . urlencode("Art thou not Romeo, and a Montague?");
//user_id=1234&body=Art+thou+not+Romeo%2C+and+a+Montague%3F
$canonical_string = $API_KEY . $http_date . $parameters;
$b64_mac = base64_encode(hash_hmac('sha1', $canonical_string, $SECRET_ACCESS_KEY,true));
$authentication = "Zeep " . $API_KEY . ":" . $b64_mac;
echo($authentication);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment