facebook_sdk.dtl 1.2 KB

12345678910111213141516171819202122232425262728293031
  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. if(setFbIframe){
  6. var inIframe= top!=self;
  7. setFbIframe(inIframe);
  8. if(inIframe && response.status == 'connected' && fbLogin)
  9. FB.api("/me?fields=id,username,first_name,last_name,email,birthday", function(response){ fbLogin(response);});
  10. }
  11. });
  12. };
  13. function fb_login(){
  14. FB.getLoginStatus(function(response){
  15. if(response.status == 'connected'){
  16. if(fbLogin) FB.api("/me?fields=id,username,first_name,last_name,email,birthday", function(response){fbLogin(response);});
  17. } else FB.login(function(r){
  18. if(r.authResponse && fbLogin) FB.api("/me?fields=id,username,first_name,last_name,email,birthday", function(response){fbLogin(response);});
  19. }, {scope: 'email,user_birthday'});
  20. });
  21. }
  22. (function(d){
  23. var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
  24. if (d.getElementById(id)) {return;}
  25. js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js?v=2";
  26. ref.parentNode.insertBefore(js, ref);
  27. }(document));
  28. </script>