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
def parse_signed_request | |
signed_request = params['signed_request'] | |
@appdata = '' | |
if signed_request.nil? or signed_request.empty? | |
else | |
encoded_sig, encoded_params = signed_request.split('.') | |
decoded_sig = UrlSafeBase64.decode64(encoded_sig) | |
decoded_params = Yajl::Parser.parse(UrlSafeBase64.decode64(encoded_params)) | |
@sigr = decoded_params |
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
<?php | |
function parse_signed_request($signed_request, $secret) { | |
list($encoded_sig, $payload) = explode('.', $signed_request, 2); | |
// decode the data | |
$sig = base64_url_decode($encoded_sig); | |
$jsondata = base64_url_decode($payload); | |
$data = json_decode($jsondata, true); | |
if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') { |
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
// If you put the signed_request php in a separate file, include it in your main page | |
<?php | |
include_once('lib/signed_request.php'); | |
?> | |
// Then you need to assign the app_data param and key/value pairs to a JS variable | |
// The appSecret in this case is stored in the php config file | |
<script type="text/javascript"> | |
window.fb_signed_request = {app_data:'<?php echo grab_app_data($_REQUEST['signed_request'], AppInfo::appSecret()); ?>'}; | |
</script> |
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
<div id="fb-root"></div> | |
<script src="//connect.facebook.net/en_US/all.js"></script> | |
<script> | |
FB.init({appId:'156294357760329', status:true, cookie:true, oauth:true, xfbml:true}); | |
</script> | |
<script type="text/javascript" charset="utf-8"> | |
if (!document.querySelectorAll){document.write('<s' + 'cript lang' + 'uage="jav' + 'ascript" src="/static/web/js/qwery.min.js"></' + 'scr' + 'ipt>');} | |
window.webtrendsAsyncInit = function() { | |
var dcs=new Webtrends.dcs().init({dcsid:"YOUR_DCS_ID",timezone:-8,plugins:{facebook:{src:"/static/js/webtrends.fb.js"}}}).track(); |
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
(function(WT){ | |
if (!window.Webtrends){ | |
return; // ensuring Webtrends has loaded | |
} | |
function hello_transform(dcs){ | |
console.log("in my hello world transform"); | |
dcs.DCSext.myparam = 'hello world'; | |
} | |
function hello_loader(dcs,config){ | |
dcs.addTransform(hello_transform,'all'); |
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
<script type="text/javascript"> | |
// this function is called by webtrends.js after it has loaded | |
window.webtrendsAsyncInit = function() { | |
var dcs=new Webtrends.dcs().init({dcsid:"your_dcs_id",timezone:-8}) | |
.addSelector('form input, form select', // find form inputs, or form selects | |
{ | |
domEvent:'onblur', // which event to listen to? | |
transform:function(dcs,o){ | |
// o is an 'options' object with o.element (dom element), o.args (object notation args) | |
o.args['fieldname'] = o.element.id; |
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
<script type="text/javascript"> | |
// this function is called by webtrends.js after it has loaded, the track, init method are chained | |
window.webtrendsAsyncInit = function() { | |
var dcs=new Webtrends.dcs().init({dcsid:"your_dcs_id",timezone:-8}).track(); | |
var dcs2=new Webtrends.dcs().init({dcsid:"your_2nd_dcs_id",timezone:-8}).track(); | |
}; | |
(function() { | |
var s = document.createElement('script'); s.type="text/javascript"; s.async = true; | |
s.src = 'http://s.webtrends.com/js/webtrends.js'; | |
var s2=document.getElementsByTagName("script")[0];s2.parentNode.insertBefore(s,s2); |
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
<!-- | |
Inclusion of file inline, not using script injection forces | |
load at a determinate point so no need for webtrendsAsyncInit function | |
--> | |
<script src="/static/webtrends.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
// create and initialize which calls dcsGetId() | |
var dcs=new Webtrends.dcs().init({dcsid:"YOUR_DCS_ID",timezone:-5}).track(); |