Created
August 1, 2011 17:44
-
-
Save qetzal/1118615 to your computer and use it in GitHub Desktop.
SSO Complete Example in 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
<html><body> | |
<script> | |
<?php | |
if (!$_REQUEST['logoff']) { | |
$profile = array( | |
'appId' => "My cool app", | |
'userId' => "234", | |
'profile' => array( | |
'email' => "[email protected]", | |
'billingPerson' => array( | |
'name' => "Tester", | |
'companyName' => "Company Name", | |
'street' => "Street", | |
'city' => "City", | |
'countryCode' => "US", | |
'postalCode' => "10001", | |
'stateOrProvinceCode' => "NY" | |
) | |
) | |
); | |
$message = json_encode($profile); | |
$message = base64_encode($message); | |
$timestamp = time(); | |
$hmac = hash_hmac('sha1', "$message $timestamp", "A1Lu7ANIhKD6"); | |
echo "var ecwid_sso_profile='$message $hmac $timestamp'"; | |
} else { | |
echo "var ecwid_sso_profile=''"; | |
} | |
?> | |
</script> | |
<script src="http://app.ecwid.com/script.js?1003"></script> | |
<script> | |
xProductBrowser(); | |
function logout() { | |
window.Ecwid.OnAPILoaded.add(function() { | |
window.Ecwid.setSsoProfile(''); | |
}); | |
} | |
</script> | |
<a href="javascript: logout()">Log out</a> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This no longer works as of July 27, 2016..
And when you click on Log out.. it generates a javascript error: window.Ecwid.setSsoProfile is not a function
They must have updated the API because http://app.ecwid.com/script.js?1003 no longer has any of the SSO code in it..