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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:31:55+00:00 2026-05-27T11:31:55+00:00

I want that users can authenticate through their fb account, and i tried their

  • 0

I want that users can authenticate through their fb account, and i tried their demo script:

 $app_id = "*****";
 $app_secret = "*****";
 $my_url = "http://localhost/fb/fb.php";

 session_start();
 $code = $_REQUEST["code"];

 if(empty($code)) {
 $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
 $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" 
   . $app_id . "&redirect_uri=" . urlencode($my_url) . "&state="
   . $_SESSION['state'];

 echo("<script> top.location.href='" . $dialog_url . "'</script>");
}

 if($_REQUEST['state'] == $_SESSION['state']) {
 $token_url = "https://graph.facebook.com/oauth/access_token?"
   . "client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url)
   . "&client_secret=" . $app_secret . "&code=" . $code;

 $response = @file_get_contents($token_url);
 $params = null;
 parse_str($response, $params);

 $graph_url = "https://graph.facebook.com/me?access_token=" 
   . $params['access_token'];

 $user = json_decode(file_get_contents($graph_url));
 echo("Hello " . $user->name);
 echo "$user->name";
}
else {
 echo("The state does not match. You may be a victim of CSRF.");

}

The problem is that after a successful login only the “Hello” string is displayed, but my $user->name is not showed.

  • 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-27T11:31:56+00:00Added an answer on May 27, 2026 at 11:31 am

    Even though this is official FB code (I didn’t realize that at the start, sorry), I recommend you debug it to see what goes wrong.

    • Activate error reporting
    • Remove the @ in front of all calls – it suppresses the output of errors
    • Look what address $graph_url contains and whether you can access it in your browser
    • See whether the call to $graph_url works out (output the result)
    • See whether the json_decode() works out (output the result)

    if this is a global or Facebook issue, you may need to talk to Facebook about what is wrong with their demo code.

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

Sidebar

Related Questions

Ultimately I want to create a desktop app that allows users to update their
When I disabled Numeric UpDown control I want that user can still read its
I want to post on twitter wall but don't want that user can edit
I want to encrypt a URL variable so that the user can't see the
I want to setup a table that can: Save the data on the user's
I want a widget that allows users to add a request if that request
I am creating a model for users and I want that property joined was
I want to create a web application that allows users to sign up, register
I have a JFileChooser that lets users choose an image for themselves. I want
I've to develop an android application that allows users to chat I want to

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.