Skip to content

Instantly share code, notes, and snippets.

@bonnie
bonnie / api_sample.py
Last active September 25, 2015 19:00
Python file demonstrating signature calculation for 500friends Security API
#python3
from urllib.parse import urlencode,quote
from hashlib import md5
from collections import OrderedDict
ACCOUNT_ID = 'ACCOUNT_ID'
SECRET_KEY = 'SECRET KEY'
def array_to_sorted_string(self, inArray):
@bonnie
bonnie / surprise_and_delight.css
Last active August 29, 2015 13:57
Surprise and Delight CSS
.surprise{
color:#cc0000 !important;
}
.surprise_widget .surprise-body .info .msg b {
color: #cc0000 !important;
}
.surprise_widget .surprise-body .points{
background: url(https://d3aa0ztdn3oibi.cloudfront.net/merchant/28a36ee57353ac113fa300682d1b8cd64c.png) no-repeat 0 0 !important;
}
.surprise_widget .surprise-body .info form #claim {
<!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')
}
<html>
<head>
<script type='text/javascript'>
// production widget JavaScript
document.write(unescape("%3Cscript%20src='"+(('https:' == document.location.protocol ? 'https://' : 'http://') + 'd3aa0ztdn3oibi.cloudfront.net/javascripts/ff.loyalty.widget.js')+"'%20type='text/javascript'%3E%3C/script%3E"));
// staging widget JavaScript; uncomment the line below and comment the line above to use the staging environment
//document.write(unescape("%3Cscript%20src='"+(('https:' == document.location.protocol ? 'https://' : 'http://') + 'd1iwtomgj4ct8d.cloudfront.net/javascripts/ff.loyalty.widget.stage.js')+"'%20type='text/javascript'%3E%3C/script%3E"));
<div class="headline">
You're almost there! Enter a password for your new account.
</div>
<div class="details">
When logging in to your account, your username will be your email address: {{ customer.email }}.
</div>
<form id='password_form' action='https://mysite.com/account_creation.php'>
Password: <input type="password" name="password1">
<?php
// arguments considered for security in the post-purchase widget
define(PPW_SECURITY_ARGS, serialize(array('wid', 'email', 'value', 'event_id', 'event_type', 'products', 'channel', 'sub_channel', 'sub_channel_detail', 'external_customer_id','name','first_name','last_name','address_line_1','address_line_2','city','state','postal_code','country','home_phone','work_phone','mobile_phone','birthdate','home_store')));
define(SECRET_KEY, <<your secret key>>);
define(WID, <<your widget id>>);
function array_to_sorted_string($a) {
ksort($a);
%YAML 1.2
---
# examples of 500friends LoyaltyPlus security signature calculations based on API parameters
# the parameters in the final_url are alphabetized for easier code comparison
# v. 1.1
UUID: ABCDEFGHIJKLMNO
SECRET_KEY: 12345678901234567890123456789012
ENV: production
TEST_TYPE: API
%YAML 1.2
---
# examples of 500friends LoyaltyPlus Post-Purchase Widget security signature calculations
# v 1.1
UUID: ABCDEFGHIJKLMNO
SECRET_KEY: 12345678901234567890123456789012
WID: 12345ABCDE
ENV: production
TEST_TYPE: PPW
<script src="https://d3aa0ztdn3oibi.cloudfront.net/javascripts/ff.loyalty.widget.js" type="text/javascript"></script>
<iframe id="ff_member_iframe" style="width:769px;height:1045px;border:0" frameBorder="0"></iframe>
<script type="text/javascript">
_ffLoyalty.initialize( "YOUR_ACCOUNT_ID" );
_ffLoyalty.loadIframe({ email: "CUSTOMER_EMAIL", auth_token: "AUTH_TOKEN"});
</script>
@bonnie
bonnie / batch_api.php
Last active August 29, 2015 14:21
PHP batch_api example
<?php
/* general constants for the account and end point */
$UUID = "ABCDEF123456";
$SECRET_KEY = "ABCDEFGHIJKLMNO1234567890123456";
$SERVER = 'https://api-stage.500friends.com';
$ENDPOINT = '/batch_api';
/* create hash for post data */
$post_data = array(