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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:08:24+00:00 2026-05-30T22:08:24+00:00

I was developing Facebook Based Authentication for one of my app, earlier time i

  • 0

I was developing Facebook Based Authentication for one of my app, earlier time i was using following code From Nettuts Tutorial

but when graph api 3.0 came out i can add this same code for my new web app, how can i generate a login as the about link?

i am using following code, but dont know how to do session in it?

========================================================================

  • 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-30T22:08:26+00:00Added an answer on May 30, 2026 at 10:08 pm

    Using the Facebook PHP SDK, you need to redirect to Facebook’s OAuth dialog, and then use the returning request to authenticate your user.

    Facebook have the following sample on http://developers.facebook.com/docs/authentication/:

    <?php
    
    $app_id = "YOUR_APP_ID";
    $app_secret = "YOUR_APP_SECRET";
    $my_url = "YOUR_URL";
    
    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);
    }
    else {
      echo("The state does not match. You may be a victim of CSRF.");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been developing a Facebook app using Google App Engine in Python and the
I am currently developing a Facebook App (it's not my first one) and I
I am developing a facebook app using php SDK, my app is small and
I am developing a Facebook App in which I get some text from the
I'm developing a facebook app with rails that uses external apis from my own
I'm developing a facebook app which has the following structure: Browser window (facebook.com/page/xxxx) --
I am developing simple facebook canvas app. I was following this page in documentation:
I'm developing an app which will allow me to post on Facebook. But I
I am developing a facebook app using PHP. I am able to login using
I am developing a facebook app where users watch videos from a playlist and

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.