Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7860311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:14:20+00:00 2026-06-02T22:14:20+00:00

I am using fb login connect in my demo site : I used this

  • 0

I am using fb login connect in my demo site :
I used this code:

  window.fbAsyncInit = function() {
      try{
        FB.init({
            apiKey: '<MY APP KEY>',
            channelUrl : 'www.google.com'
        });

        FB.getLoginStatus(function(response){
            loginHandler(); 
        });
      }catch(error){}
  };  
    function loginHandler(success,fail)
    {

        try{
            if(success){
                alert('i am if');
                FB.api('/me', function(response,fail) {
                    alert("first name == " + response.first_name + "\n ln === " + response.last_name);
                });
            }
        }catch(error){}
    }

    $('#login').bind('click', function(response) {
        try{
            FB.login(loginHandler, {scope: 'email,user_likes'});
        }catch(error){}
    });

    $('#logout').bind('click', function() {
        try{
            FB.logout(function(response){});
        }catch(error){}
      });

Now my problem is that alert(‘i am if’); is showing every time whether I passed correct credentials to facebook or not and alert(“first name == ” + response.first_name + “\n ln === ” + response.last_name); shows undefined when user passes wrong credentials and shows correct info when user comes back passing correct info.

one possible option is to check like if(response.first_name!=undefined){blah blah....} but is it correct method of checking the authentication?

Please shed some light….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:14:22+00:00Added an answer on June 2, 2026 at 10:14 pm

    Try something like this:

    //for login
        $("#login").bind("click", function(e) {     
            var fbScope = "email,user_likes";
            FB.login(function(response) {          
               if(response.status == "connected"){
                   console.log("Logged in");
               }
            },{scope: fbScope});
        });
        //for checking logged in status
        FB.getLoginStatus(function(response){
            if (response.authResponse) {    
                var accessToken = response.authResponse.accessToken;
                FB.api('/me', function(response) {
                    console.log('I m still loggedin');
                });         
            }
        });
        //for logout
        $("#logout").live("click", function(e) {        
            FB.getLoginStatus(function(response){           
                if(response.status == "connected"){
                    FB.logout(function(response) {
                        console.log("I m logged out now");                  
                    });
               } else {
                    console.log("Not Logged logged in");
               }
            });
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using login function in my site with session. This session of mine gets
On the front-end, I've initialised FB and login using: window.fbAsyncInit = function () {
I've set up Facebook connect with my app using the demo project provided by
I cannot login using email in CakePHP 2.1, when i try with username then
I am trying to login using the library Mechanize. This the output i get
So we have been using the same login gode to connect to various domains
I'm trying to connect to http://cmis.demo.nuxeo.org/nuxeo/atom/cmis/ with NSURLConnection . This demo web service is
After i login using Facebook connect,I need to redirect user to particular URL.The below
I'm using Rails, Devise, and Omniauth, and I'm trying to login using facebook connect.
I am using facebook sdk and facebook connect for integrating fb into my site

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.