Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- function handle_fb_data(response) {
- FB.api('/me', function (response) {
- console.log('Successful login for: ' + response.name);
- console.log('Прилетело из ФБ: ' + JSON.stringify(response));
- // alert('Прилетело из ФБ: '+JSON.stringify(response));
- $.ajax({
- type: 'post',
- url: '/login.php',
- data: response,
- success: function (msg) {
- console.log(response);
- if ((msg == 'зарегались') || (msg == 'залогинились')) {
- window.location.reload();
- }
- },
- error: function () {}
- })
- });
- }
- function fb_login() {
- FB.getLoginStatus(function (response) {
- if (response.authResponse) {
- console.log('Welcome! Fetching your information.... ');
- handle_fb_data(response);
- } else {
- console.log('Юзер был не залогинен в самом ФБ, запускаем окно логинизирования');
- FB.login(function (response) {
- if (response.authResponse) {
- console.log('Welcome! Fetching your information.... ');
- handle_fb_data(response);
- } else {
- console.log('Походу пользователь передумал логиниться через ФБ');
- }
- }, {scope: 'public_profile,email'});
- }
- }, true);
- }
- window.fbAsyncInit = function () {
- FB.init({
- appId: '---',
- cookie: true,
- xfbml: true,
- version: 'v3.2'
- });
- FB.AppEvents.logPageView();
- };
- (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 = "https://connect.facebook.net/en_US/sdk.js";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));
- </script>
Add Comment
Please, Sign In to add comment