Created
April 6, 2012 23:16
-
-
Save rtekie/2323879 to your computer and use it in GitHub Desktop.
LoyaltyPlus Member Page code sample
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
<!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