facebook_sdk.dtl 1.2 KB

12345678910111213141516171819202122232425262728
  1. <script>
  2. window.fbAsyncInit = function() {
  3. FB.init({ appId: '{{appid}}', channelUrl: ' {{channelUrl}}', status: true, cookie: true, xfbml: true, oauth: true });
  4. FB.getLoginStatus(function(response) {
  5. var inIframe= top!=self;
  6. if(inIframe && response.status == 'connected' && fbLogin)
  7. FB.api("/me?fields=id,first_name,last_name,email,birthday,cover", function(response){ fbLogin(response);});
  8. });
  9. };
  10. function fb_login(){
  11. FB.getLoginStatus(function(response){
  12. if(response.status == 'connected'){
  13. if(fbLogin) FB.api("/me?fields=id,first_name,last_name,email,birthday,cover", function(response){fbLogin(response);});
  14. } else FB.login(function(r){
  15. if(r.authResponse && fbLogin) FB.api("/me?fields=id,first_name,last_name,email,birthday,cover", function(response){fbLogin(response);});
  16. }, {scope: 'email,user_birthday'});
  17. });
  18. }
  19. (function(d){
  20. var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
  21. if (d.getElementById(id)) {return;}
  22. js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js?v=2";
  23. ref.parentNode.insertBefore(js, ref);
  24. }(document));
  25. </script>