Skip to content

Instantly share code, notes, and snippets.

@rtekie
Created April 6, 2012 23:16
Show Gist options
  • Save rtekie/2323879 to your computer and use it in GitHub Desktop.
Save rtekie/2323879 to your computer and use it in GitHub Desktop.
LoyaltyPlus Member Page code sample
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>LoyaltyPlus Member Page Sample</title>
<script src="https://d3aa0ztdn3oibi.cloudfront.net/javascripts/ff.loyalty.widget.js" type="text/javascript"></script>
</head>
<body>
<h1>SINGLE SIGN-ON MEMBER PAGE SAMPLE</h1>
<?php
// get uuid and email
$uuid = "YOUR_ACCOUNT_ID";
$email = "CUSTOMER_EMAIL";
// construct api call
$secret_key = "YOUR_SECRET_KEY";
$params = array();
$params["email"] = $email;
$params["uuid"] = $uuid;
ksort($params);
$string_to_hash = $secret_key;
foreach ($params as $key => $val) {
$string_to_hash .= $key.$val;
}
$params["sig"] = md5($string_to_hash);
$api_url = "https://loyalty.500friends.com/data/customer/auth_token?";
foreach ($params as $key => $val) {
$api_url .= "$key=".urlencode($val)."&";
}
// make api call
$c = curl_init($api_url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($c);
curl_close($c);
$parsed_response = json_decode($response, true);
$auth_token = $parsed_response["data"]["auth_token"];
// construct js call arguments
$load_args = "{email: '".$email."', auth_token: '".$auth_token."'}";
?>
<iframe id='ff_member_iframe' style="width: 100%; height: 600px; scrolling='no'" frameBorder="0"></iframe>
<script type='text/javascript'>
_ffLoyalty.initialize("<?php echo $uuid; ?>");
_ffLoyalty.loadIframe(<?php echo $load_args; ?>);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment