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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:22:37+00:00 2026-05-30T09:22:37+00:00

I am having trouble to authenticate users through the Facebook PHP SDK. Basically I

  • 0

I am having trouble to authenticate users through the Facebook PHP SDK.

Basically I want to show a “log in with facebook” button if the user is not already authenticated. Otherwise, present the user name. Here is the code:

require_once 'facebook.php';
$facebook = new Facebook(array(
        'appId' => 'XXX',
        'secret' => 'XXX',
        'cookie' => true
));
$userId = $facebook->getUser();
var_dump($userId);
if ($userId) {
    $userInfo = $facebook->api('/' . $userId);
    echo "Welcome, {$userInfo['name']}";
} else {
    echo '<a href="' . $facebook->getLoginUrl() . '">' .
'<img src="images/icon_facebook_login.png" alt="Login with Facebook" /></a>';
}

The trouble is I always get 0 from $facebook->getUser(). I looked at the code in base_facebook.php and while processing the function a request param signed_request is expected in the return URL. The only params I see in the URL Facebook returns are code and state.

Any ideas what I might have messed up? Thanks in advance.

EDIT: As suggested by ogi I made a hand-made request with the code param to graph.facebook.com/oauth/access_token and I did receive access_token. Now, the only question remaining is how to accomplish this through the PHP SDK?

  • 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-30T09:22:39+00:00Added an answer on May 30, 2026 at 9:22 am

    The problem was I didn’t copy fb_ca_chain_bundle.crt file to the directory where facebook.php and base_facebook.php reside. In getAccessTokenFromCode() the code to facebook.com/oauth/access_token... fails but since they capture the exception, it is very hard to figure out.

    Hopefully this will save someone some hours of code tracing.

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

Sidebar

Related Questions

I'm having a bit of trouble working with the facebook JS SDK. The 'auth.login'
Having trouble linking the Stomp.framework into an iPhone SDK application. http://code.google.com/p/stompframework/ I follow the
Having trouble looping through multiple rows in a SQL table and getting the info
I want to be able to post on users Twitter feed from a Facebook
I'm having trouble using python function decorators in Google's AppEngine. I'm not that familiar
I am having trouble sending emails with PHP. Can you see any problems in
I want to develop an authentication module using PAM, but I'm having trouble getting
I am currently working through http://ruby.railstutorial.org/chapters/sign-in-sign-out#sec:current_use r] 1 and I am having trouble understanding
Having trouble disabling the active state. Any thoughts? So when a user click on
I'm trying to get OAuth through SoundCloud set up, but I'm having tremendous trouble.

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.