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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:34:37+00:00 2026-05-28T17:34:37+00:00

I had some really complicated code, and now I’ve made it ridiculously simple, and

  • 0

I had some really complicated code, and now I’ve made it ridiculously simple, and it doesn’t work.

Currently it simply takes me back to the page with the login URL echoed out.

Code is here:

<?php
require 'facebook.php';

// Create our application instance
// (replace this with your appId and secret).
$facebook = new Facebook(array(
  'appId'  => 'sd',
  'secret' => 'sda',
));

// Get User ID
$user = $facebook->getUser();


if($user) {
    echo $user;
} else {
    $loginUrl = $facebook->getLoginUrl(array('redirect_uri'=>'http://www.facebook.com/pages/CharlesTestPage/225802194155435?sk=app_252946408094785','scope'=>'email'));
  echo $loginUrl;
}
exit;
?>

Please. I have spent a whole paid work day on this now, and am at the point of crying, not only for myself but for my boss.

Cry.

Edit: OK, the weird thing is, if I have the redirect_uri set to the facebook tab, if it’s not authenticated itself, then it constantly redirects in an infinite loop. However, if I remove the redire

  • 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-28T17:34:38+00:00Added an answer on May 28, 2026 at 5:34 pm

    This is what’s working for me using PHP SDK 3.1.1. Try it and let us know if this works:

    include('facebook.php');
    session_start();
    
    //facebook application
    $config['appid' ] = "YOUR_APP_ID";
    $config['secret'] = "YOUR_APP_SECRET";
    $config['baseurl'] = "http://example.com/facebookappdirectory";
    $config['appbaseurl'] = "http://apps.facebook.com/your-app-name";
    
    
    // Create our Application instance.
    $facebook = new Facebook(array(
      'appId'  => $config['appid'],
      'secret' => $config['secret'],
      'cookie' => true,
    ));
    
    $user = $facebook->getUser();
    $loginUrl = $facebook->getLoginUrl(
            array(
                'scope' => 'email'
            )
    );
    
    if ($user) {
      try {
        //get user basic description
        $userInfo = $facebook->api("/$user");
        $fb_access_token = $facebook->getAccessToken();
      } catch (FacebookApiException $e) {
        //you should use error_log($e); instead of printing the info on browser
        error_log('APP ERROR: '.$e); 
        $user = null;
      }
    }
    
    if (!$user) {
        echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
        exit;
    }
    
    if (isset($_GET['code'])){
        header("Location: " . $config['appbaseurl']);
        exit;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple problem... I had some comments on my code and deleted them and got
I had some code that ran commands through Runtime.getRuntime.exec(String) , and it worked on
I had some decryption code (using wincrypt.h ) that lived within my FileReader.cpp class.
I just had some very strange behavior with a simple php script I was
I have seen a lot of upload forms hacked, and some had some really
Just looking for some advice really. I've had to write some integration tests to
Ive had some svn woes with an Xcode project and now using an older
I had some time this afternoon to run a head to head comparison between
I had some site templates designed for me recently. I got the final HTML
I had some problems with my subversion server and i had to restore it

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.