Guest User

Untitled

a guest
Feb 16th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. <script>
  2. function handle_fb_data(response) {
  3. FB.api('/me', function (response) {
  4. console.log('Successful login for: ' + response.name);
  5. console.log('Прилетело из ФБ: ' + JSON.stringify(response));
  6. // alert('Прилетело из ФБ: '+JSON.stringify(response));
  7.  
  8. $.ajax({
  9. type: 'post',
  10. url: '/login.php',
  11. data: response,
  12. success: function (msg) {
  13. console.log(response);
  14. if ((msg == 'зарегались') || (msg == 'залогинились')) {
  15. window.location.reload();
  16. }
  17. },
  18. error: function () {}
  19. })
  20. });
  21. }
  22.  
  23. function fb_login() {
  24. FB.getLoginStatus(function (response) {
  25. if (response.authResponse) {
  26. console.log('Welcome! Fetching your information.... ');
  27. handle_fb_data(response);
  28. } else {
  29. console.log('Юзер был не залогинен в самом ФБ, запускаем окно логинизирования');
  30. FB.login(function (response) {
  31. if (response.authResponse) {
  32. console.log('Welcome! Fetching your information.... ');
  33. handle_fb_data(response);
  34. } else {
  35. console.log('Походу пользователь передумал логиниться через ФБ');
  36. }
  37. }, {scope: 'public_profile,email'});
  38. }
  39. }, true);
  40. }
  41. window.fbAsyncInit = function () {
  42. FB.init({
  43. appId: '---',
  44. cookie: true,
  45. xfbml: true,
  46. version: 'v3.2'
  47. });
  48.  
  49. FB.AppEvents.logPageView();
  50.  
  51. };
  52.  
  53. (function (d, s, id) {
  54. var js, fjs = d.getElementsByTagName(s)[0];
  55. if (d.getElementById(id)) {
  56. return;
  57. }
  58. js = d.createElement(s);
  59. js.id = id;
  60. js.src = "https://connect.facebook.net/en_US/sdk.js";
  61. fjs.parentNode.insertBefore(js, fjs);
  62. }(document, 'script', 'facebook-jssdk'));
  63. </script>
Add Comment
Please, Sign In to add comment