-2

Previously login via facebook was working fine without any issues.Login via Facebook using Javascript SDK is implement on the PHP codeigniter website. But after July 2017 update I am unable to login to website via facebook.

Below is my code.Kindly assist.

<script type="text/javascript" defer="defer">
            window.fbAsyncInit = function () {
             FB.init({
             appId: "<?php echo $global['facebook_app_id']; ?>", // App ID
             channelUrl: "<?php echo base_url(); ?>channel.html", // Channel File 
             status: true, // check login status
             cookie: true, // enable cookies to allow the server to access the session
             picture: "http://www.fbrell.com/f8.jpg",
             xfbml: true  // parse XFBML
             });
             };
             // Load the SDK Asynchronously
             (function (d) {
             var js, id = "facebook-jssdk", ref = d.getElementsByTagName("script")[0];
             if (d.getElementById(id)) {
             return;
             }
             js = d.createElement("script");
             js.id = id;
             js.async = true;
             js.src = "//connect.facebook.net/en_US/all.js";
             ref.parentNode.insertBefore(js, ref);
             }(document));
        </script>



                function loginMe(path)
            {
                var params1 = '';
                FB.login(function (response) {
                    if (response.authResponse) {
                        console.log('Welcome!  Fetching your information.... ');
                        FB.api('/me', function (response) {
                            var params = "username=" + response.username + "&first_name=" + response.first_name + "&last_name=" + response.last_name + "&email=" + response.email + "&fb_id=" + response.id + "&gender=" + response.gender + "&birthday=" + response.birthday + "&action_type=fb_login";
                            //var params="email="+response.email; 
                            FB.api('/me/friends', function (response) {
                                //                                 alert(JSON.stringify(response));
                                var i = 0;
                                $.each(response.data, function (key, val) {
                                    i++;
                                });
                                params1 = "&facebook_friend_count=" + i;
                            });
                            if (typeof (response.email) === "undefined") {
                                alert('Sorry, there is technical problem to fetch data from facebook, please try again.');
                                window.parent.location = path;
                            }
                            jQuery.ajax({
                                type: 'post',
                                url: path + 'login-with-facebook',
                                data: params,
                                success: function (msg) {
                                    if (msg != '' && msg != 'fail') {
                                        window.location.href = path + "login-with-fb/" + msg;
                                    }
                                    else
                                    {
                                        if (msg == 'fail')
                                            alert('Sorry, there is technical problem to fetch data from facebook, please try again.');
                                        window.parent.location = path;
                                    }
                                }
                            });
                        });

                    } else {
                        //console.log('User cancelled login or did not fully authorize.');
                    }
                }, {"scope": "email,read_stream"});
            }               

Every time after entering my login credentials I am getting alert " Sorry, there is technical problem to fetch data from facebook, please try again." I am unable to fetch user details from Facebook.

rayman paul
  • 23
  • 1
  • 6

2 Answers2

0

https://developers.facebook.com/docs/facebook-login/permissions/#reference-read_stream

user_posts may fix your problem

https://developers.facebook.com/docs/facebook-login/permissions/#reference-user_posts

Kevin P
  • 601
  • 3
  • 9
0

Version 2.3 of the Facebook API was deprecated on July 8, 2017. Update your configuration code to use a later version and make sure everything still works. You should probably also review changes in the upgrade guide.

Here is a configuration example from the documentation:

window.fbAsyncInit = function() {
  FB.init({
    appId            : 'your-app-id',
    autoLogAppEvents : true,
    xfbml            : true,
    version          : 'v2.10'  // <-- Right here
  });
  FB.AppEvents.logPageView();
};
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • Tried making changes as per upgrade guide. Still getting the same issue. – rayman paul Jul 25 '17 at 22:53
  • Did you change the `version` value as I showed in my answer? – ChrisGPT was on strike Jul 25 '17 at 22:53
  • Please edit your question and add your code there. You can select it and press Ctrl+K or click the `{}` button to format it properly. – ChrisGPT was on strike Jul 25 '17 at 23:02
  • I added my current Facebook java script sdk code. The version field was not there. When I try adding the version field the pop up for facebook login got disabled. – rayman paul Jul 25 '17 at 23:09
  • @CBroe, good catch. I got it right in my comment on the question and then wrong in my answer. I've fixed that. – ChrisGPT was on strike Jul 26 '17 at 12:08
  • @raymanpaul, what does "the pop up for facebook login got disabled" mean? Were you careful to make sure your JS object was valid (e.g., by adding a comma after the existing `xfbml` line)? Do you see any errors in your developer console? Note also that the `version` argument is currently mandatory. I'm not sure if it always was. – ChrisGPT was on strike Jul 26 '17 at 12:14