Skip to content

Instantly share code, notes, and snippets.

@abernier
Created January 13, 2012 11:13
Show Gist options
  • Save abernier/1605592 to your computer and use it in GitHub Desktop.
Save abernier/1605592 to your computer and use it in GitHub Desktop.
FB test
(function (d) {
var el,
klass = 'fb-login-button';
if (d.getElementsByClassName(klass).length) {return;}
el = d.createElement('div');
el.setAttribute('class', klass);
el.setAttribute('data-show-faces', true);
el.setAttribute('data-width', 200);
el.setAttribute('data-max-rows', 1);
d.body.insertBefore(el, d.body.firstElementChild);
}(document));
(function (d) {
var el,
id = 'fb-root';
if (d.getElementById(id)) {return;}
el = d.createElement('div');
el.id = id;
d.body.insertBefore(el, d.body.firstElementChild);
}(document));
(function(d, s, id, appId) {
var js,
fjs = d.getElementsByTagName(s)[0];
window.fbAsyncInit = function () {
FB.init({
appId : '' + appId, // App ID
//channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional initialization code here
};
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/fr_FR/all.js#xfbml=1&appId=" + appId;
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk', 312338892143875));
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title></title>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="http://jashkenas.github.com/coffee-script/extras/coffee-script.js"></script>
<script type="text/coffeescript">
window.fbAsyncInit = ->
FB.api '/fql', 'get',
q: JSON.stringify
query1: 'SELECT uid2 FROM friend WHERE uid1=me()'
query2: "SELECT uid, name, pic_square, online_presence, can_post FROM user WHERE is_app_user AND uid IN (SELECT uid2 FROM #query1) AND strpos(lower(name), \'a\') >= 0 ORDER BY name LIMIT 0, 2"
, (response) ->
console.log response.data[1].fql_result_set
</script>
</head>
<body>
<script src="facebook-sdk.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment