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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:35:11+00:00 2026-05-12T18:35:11+00:00

I am doing my second Facebook connect site. On my first site, I used

  • 0

I am doing my second Facebook connect site. On my first site, I used the facebook coonect FBML to sign a user in, then I could access other information via the PHP Client. With this site, using the same exact code, it doesn’t seem to be working. I’d like someone to be able to sign in using the Facebook button:

<fb:login-button length="long" size="medium" onlogin="facebook_onlogin();"></fb:login-button>

After they have logged in, the facebook_onlogin() function makes some AJAX requests to a PHP page which attempts to use the Facebook PHP Client. Here’s the code from that page:

    $facebook = new Facebook('xxxxx API KEY xxxxx', 'xxxxx SECRET KEY xxxxx');
    //$facebook->require_login(); ** I DONT WANT THIS LINE!!

    $userID = $facebook->api_client->users_getLoggedInUser();

    if($userID) {

        $user_details = $facebook->api_client->users_getInfo($userID, 'last_name, first_name'); 
        $firstName = $user_details[0]['first_name']; 
        $lastName = $user_details[0]['last_name']; 

        $this->view->userID = $userID;
        $this->view->firstName = $firstName;
        $this->view->lastName = $lastName;
    }

The problem is that the PHP Client thinks I don’t have a session key, so the $userID never get set. If I override the $userID with my facebook ID (which I am logged in with) I get this error:

exception ‘FacebookRestClientException’ with message ‘A session key is required for calling this method’ in C:\wamp\www\mab\application\Facebook\facebookapi_php5_restlib.php:3003

If I uncomment the require_login(), it will get a session ID, but it redirects pages around a lot and breaks my AJAX calls. I am using the same code I successfully did this with on another site. Anyone have any ideas why the PHP client don’t know about the session ID after a user has logged in with the connect button? Any ideas would be greatly appreciated. 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-05-12T18:35:11+00:00Added an answer on May 12, 2026 at 6:35 pm

    You can extract the user id without a API call, directly from the cookies, by using:

    $facebook->get_loggedin_user();
    

    Note that this is on the main $facebook object, not the api_client object it contains.

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

Sidebar

Related Questions

Doing some homework here (second assignment, still extremely green...). The object is to read
It appears that second windows are not closing. Here is what I am doing....
Doing my first SL4 MVVM RIA based application and i ran into the following
Doing my first tryouts with foreign keys in a mySQL database and are trying
Doing code analysis of the project and get the message Reference-counted object is used
This is my second semester doing Java and so please be patient. Part of
My app uses Facebook Javascript SDK authorization on client side, and for authorized user
I have examples. :) The first, on Facebook: it's a triangle (in the top-right
I got this app that records the user's Facebook ID in a MySQL table,
I'm doing this facebook comments for a friend and I can't get any info

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.