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

  • SEARCH
  • Home
  • 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 6898979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:21:51+00:00 2026-05-27T07:21:51+00:00

I have some troubles when using javascript code for Facebook invite friends. Details: User

  • 0

I have some troubles when using javascript code for Facebook invite friends. Details:

  1. User Facebook A already authorized our web application, and give us the permission to offline-access their access tokens.

  2. User A logged in into our web. The system detect that A synchronized his account (on our web) with Facebook, so it retrieve A’s information from Facebook.

  3. In the same browser, A open a new tab, and log out of Facebook.

  4. A user B borrows A computer, and then logged in Facebook but with his account: user Facebook B.

  5. He move to our web (the tab that A already opened), and click “Invite friends”. The list show all the friends of user B, not user A.

This scenario (though very rarely happens), troubled our group testers, because it may causes un-expected behavior for our web application (a user may think he synchronize the wrong Facebook account).

To stop that case, I want to differentiate who is currently logged-in Facebook (user B), with the user has authorized our application (user A). Currently I’m checking like this:

function showInvitationDialog() {

            FB.init({ 
                    appId:'${appId}', 
                    cookie: false, 
                    status: true, 
                    xfbml: true 
                });

            FB.getLoginStatus(function (response) {
                if (response.session) {
                    if (response.session.uid != ${fbId}) {
                        alert("You are currently logged in to FB with another account (different to the account you registered). Please make sure that you don't accidently use others FB account to invite");
                        return;
                    }
                }

                var request_ids = FB.ui({ method: 'apprequests',
                                    message: '<@spring.message code="friends.invitation.message" />',
                                    data: 'hello'});
            });
    }

The above code works for most case, but it have a problem:

  1. If user X is logged in Facebook user X’, and he authorize our app already: response.session.uid = X_FacebookId -> ok, we know who he is
  2. If user X is not logged to Facebook, response.session == undefined
  3. If user X is logged in with Facebook user X’, and he hasn’t auhthorized our application yet, response.session == undefined

So I can not differentiate the case 2 vs case 3. In both case, the results from getLoginStatus is the same, but I want to solve it differently:

  • case 2 -> continue to call the function to let “Login dialog” popup
  • case 3 -> informs the user that he has logged into the wrong Facebook
    account.

Is there any solution for this situation? Any idea will be greatly appreciated.

  • 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-05-27T07:21:52+00:00Added an answer on May 27, 2026 at 7:21 am

    getLoginStatus() returns a Json object which is like :

    {
        status: one of 'not_authorized' / 'connected' / 'unknown'
        authResponse: ....
    }
    

    not_authorized means they are logged into facebook but haven’t authorized your app,
    connected means they have authorized the app,
    unknown means they are not logged into facebook.

    (from memory so might not be exact)

    Also, you might want to consider listening for auth events, which might make this problem easier. http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some troubles with memory leaks in JavaScript. I'm using the Leak Memory
I have some troubles with positioning my label/password field. With this code they both
I have been successfully using my code with the javascript library in the ANTLR
I'm having some trouble using constraints correctly. I have three tables, 'item', 'store' and
I have trouble using sed. I need to replace some lines in very deprecated
I have created some rounded navigation tabs using CSS and am having trouble when
I have a ASP.NET MVC site using Membership Provider. I have trouble testing some
I have just installed Delphi 2010 and got some troubles with idHTTP component. If
I have a table generated from some PHP code that lists a SMALL amount
I know that people have had some trouble with undefined CssClass values when using

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.