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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:46:41+00:00 2026-05-24T18:46:41+00:00

Well I just tried updating my script and I keep getting a return of

  • 0

Well I just tried updating my script and I keep getting a return of 0 for getUser()

here are a couple snippets that i changed

old code

<?php

require_once("src/facebook.php");

class cfb
{
    public  $fb;
    public  $_fb_user;
    public  $_fb_details;
    public  $_fb_app_id         = '**************';
    private $_fb_app_secret     = '***************';
    private $_user;

    function __construct()
    {
        $this->fb = new Facebook(array(
        'appId'  => $this->_fb_app_id,
        'secret' => $this->_fb_app_secret,
        'cookie' => true,
        ));

        $this->_fb_user = $this->fb->getSession();

        $this->DB = new db();
        $this->_user = new user();
    }

    public function session_exists()
    {

        // see if there is a session stored, if so make sure the session is still good on facebooks end
        if($this->_fb_user) {

            // test if session is still good
            try
            {
                $me = $this->fb->api('/me');
            }
            catch(FacebookApiException $e){

                error_log($e);

            }

            if(!empty($me)) { 

                return true; 

            }

        } else { 

            return false;

        }
    }


new code

<?php

require_once("src/facebook.php");

class cfb
{
    public  $fb;
    public  $_fb_user;
    public  $_fb_details;
    public  $_fb_app_id         = '*****************';
    private $_fb_app_secret     = '********************';
    private $_user;

    function __construct()
    {
        $this->fb = new Facebook(array(
        'appId'  => $this->_fb_app_id,
        'secret' => $this->_fb_app_secret,
        ));

        $this->_fb_user = $this->fb->getUser();

        $this->DB = new db();
        $this->_user = new user();
    }

    public function session_exists()
    {

        // see if there is a session stored, if so make sure the session is still good on facebooks end
        if($this->_fb_user) {

            // test if session is still good
            try
            {
                $me = $this->fb->api('/me');
            }
            catch(FacebookApiException $e){

            echo '<pre>'.htmlspecialchars(print_r($e, true)).'</pre>';

            }

            if(!empty($me)) { 

                return true; 

            }

        } else { 

            return false;

        }
    }


here is my js code

<div id="fb-root"></div>
   <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId   : '<?php echo $fb->_fb_app_id; ?>',
          status  : true, // check login status
          cookie  : true, // enable cookies to allow the server to access the session
          xfbml   : true // parse XFBML
        });

        // whenever the user logs in, we refresh the page
        FB.Event.subscribe('auth.login', function(response) {
          window.location="<?php echo $fbredirect; ?>";
        });
      };

      (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
      }());


    </script>


I can’t figure it out. was hoping it would be simple update but i guess not =/

  • 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-24T18:46:42+00:00Added an answer on May 24, 2026 at 6:46 pm

    In your JS code, add oauth:true inside the FB.init function.

    You can see the PHP SDK v.3.1.1 working with the JS SDK in the example here: https://developers.facebook.com/blog/post/534/

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

Sidebar

Related Questions

Well, just to keep it simple: I have a webform. On it a button
Well, I'm gonna be pretty straightforward here, I just have a piece of code
I have just tried to send a workbook to a friend that has a
Well I know it's not evil just not as pretty in semantics as <strong>
Maybe I just don't know .NET well enough yet, but I have yet to
I'm just starting with The Well-Grounded Rubyist, and they gave the following example: print
I just want to check if I understood well the way asynchronous Http request
I'm pretty new to APEX ( well, just started using it ~an hour ago),
A Java version of this question was just answered, and, well, I don't know
Ok another WPF question, well I guess this is just general .NET. I have

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.