Skip to content

Instantly share code, notes, and snippets.

@bonnie
Last active August 29, 2015 13:59
Show Gist options
  • Save bonnie/10691786 to your computer and use it in GitHub Desktop.
Save bonnie/10691786 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>prism member app test</title>
<script src="https://d3aa0ztdn3oibi.cloudfront.net/javascripts/ff.loyalty.widget.stage.js" type="text/javascript"></script>
<script type='text/javascript'>
function custom500FriendsCallback (arg){
alert('callback action:' + arg['action'] + ' success')
}
</script>
</head>
<body>
<h1>SINGLE SIGN-ON MEMBER APP TEST</h1>
<?php
// set uuid, email, and secret key
$uuid = "500FRIENDS_ACCOUNT_ID_FOUND_ON_PROFILE_PAGE";
// echo "uuid=".$uuid."<br />";
$email = "FILL_ME_WITH_A_TEST_EMAIL_ADDRESS";
// echo "email=".$email."<br />";
$secret_key = "500FRIENDS_ACCOUNT_SECRET_KEY";
?>
<?php
// construct api call for member iframe auth_token
$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;
}
echo $string_to_hash."<br />";
$params["sig"] = md5($string_to_hash);
$api_url = "https://loyalty-stage.500friends.com/data/customer/auth_token?";
foreach ($params as $key => $val) {
$api_url .= "$key=".urlencode($val)."&";
}
// echo $api_url."<br />"; // Url of the api call.
?>
<?php
// make api call for member iframe auth_token
$c = curl_init($api_url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($c);
curl_close($c);
// echo "response=".$response."<br />";
$parsed_response = json_decode($response, true);
var_dump($parsed_response);
$auth_token = $parsed_response["data"]["auth_token"];
// echo "<br />auth_token=".$auth_token."<br />";
?>
<?php
// construct member iframe js call arguments
$load_args = "{email: '".$email."', cross_domain: true, auth_token: '".$auth_token."'}";
// echo "loadIframe args=".$load_args."<br />";
?>
<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