Created
November 19, 2009 22:41
-
-
Save flukeout/239108 to your computer and use it in GitHub Desktop.
Zeep Mobile - Authentication header - PHP
This file contains hidden or 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
#!/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