secret
Created

Facebook connect code

  • Download Gist
my.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
window.fbAsyncInit = function () {
 
// Attach event handlers for Facebook operations:
$('[data-facebook="login"]').click($.proxy(Foobar.Social.Facebook.toggleConnection, Foobar.Social.Facebook));
$('[data-facebook="logout"]').click($.proxy(Foobar.Social.Facebook.toggleConnection, Foobar.Social.Facebook));
 
// Trigger FB loaded state:
$.event.trigger(Foobar.Events.FB_LOADED);
 
FB.init({
appId : window.fbAppId, // App ID
// channelUrl : 'http://localhost:8080/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
});
 
// Subscribe to Facebook events:
FB.Event.subscribe('auth.statusChange', Foobar.Social.Facebook.onStatusChange);
};
 
// Load the SDK asynchronously:
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
template.html
HTML
1 2 3 4
<div id="social">
<div class="fb-like" data-href="{{ url('fd') }}" data-send="false"
data-layout="button_count" data-show-faces="false"></div>
</div>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.