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 7926095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:36:27+00:00 2026-06-03T18:36:27+00:00

So I have a FB app and in some situations I need my Javascript

  • 0

So I have a FB app and in some situations I need my Javascript to load content into a div using a php file that lives in the same domain as index.php. For some of these I like to make sure that the user is still valid and/or have need of an auth token and FB user id. I achieved this by making creating an instance of the FB PHP SDK in the php file being ajax injected by the javascript and using getUser() and getAccessToken(). I have noticed, however, that sometimes inexplicably the getAccessToken() call will fail and report that it needs a valid access token to perform the action.

Is getAccessToken() a reliable (or even ideal) way to ensure a user is logged into FB or should I be doing something else (e.g. storing the access token I parse from the signed request in Javscript and passing it as a variable to the php files I am injecting)? Thanks.

  • 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-03T18:36:29+00:00Added an answer on June 3, 2026 at 6:36 pm

    Most reliable would probably be to get their details. I have, in hte past, had an instance of “getUser” return true, but the user has not actually logged on. So now I also get all their details and this works more reliably:

    $facebook = new Facebook(array(
                                'appId' => FB_APP_ID,
                                'secret' => FB_APP_SECRET,
                                'cookie' => true
                        ));
    $FB_UID=false;
    try {
        $FB_UID = $facebook->getUser();
        // This verifies the user is actually logged in. teh above can return "true" but the following will crap out and throw exception
        $FB_me = $facebook->api('/me');  // 'birthday'
        // Not needed:
        // $FB_token = $facebook->getAccessToken();
    
    } catch (FacebookApiException $e) {
        $FB_UID = false;
        $FB_me = false;
        // $FB_token = false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app which generates some files in the app directories I need
I have a rails app with some nested data that I'd like to export
I have an app that has some configuration settings stored in SharedPreference. Now I
I have an app that downloads some documents from a server and saves them
I have a small app that downloads some files from a remote (HTTP) server
I have an app that can open up some other forms at the user's
I have android app that talks to server and syncs some data int SQLite
I need some help with an app i'm making using MapKit I'm struggling with
Apple states that all apps using in-app purchases have to put this [[SKPaymentQueue defaultQueue]
I have a web page that is being displaying in a winform app 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.