Skip to content

Instantly share code, notes, and snippets.

@qetzal
Created August 1, 2011 17:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save qetzal/1118615 to your computer and use it in GitHub Desktop.
Save qetzal/1118615 to your computer and use it in GitHub Desktop.
SSO Complete Example in PHP
<html><body>
<script>
<?php
if (!$_REQUEST['logoff']) {
$profile = array(
'appId' => "My cool app",
'userId' => "234",
'profile' => array(
'email' => "test@example.com",
'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>
@GreatLakeApps
Copy link

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..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment