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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:59:27+00:00 2026-05-26T08:59:27+00:00

I’m using the PHP Facebook SDK (v.3.1.1) for building my Facebook app. At some

  • 0

I’m using the PHP Facebook SDK (v.3.1.1) for building my Facebook app.
At some point in my flow I need the user to accept my app. I’m using the following code:

// Is there an error? Redirect to explain permissions page
if(!empty($_GET['error'])) {
    $redirectUrl = APP_FACEBOOK_PAGE;
require_once(ABSOLUTE_DOCUMENTROOT_PATH.'do_redirect.inc.php');
die();  
}

// Prepare app
$facebook = new Facebook(array(
    'appId'  => APP_ID,
    'secret' => APP_SECRET,
    'cookie'=> true
));
$facebookId = $facebook->getUser();

// Changed user?
if((!empty($_SESSION['facebookAuth']['facebookId']) && $_SESSION['facebookAuth']    ['facebookId'] != $facebookId)) {
    $facebook->setAccessToken('');
    $_SESSION['facebookAuth']['facebookId'] = $facebookId;
    $redirectUrl = getRequestPermissionsUrl($facebook);
    require_once(ABSOLUTE_DOCUMENTROOT_PATH.'do_redirect.inc.php');
    die();
}

// No access token? Re-acquire it!
if($facebook->getAccessToken() == '') {
    $redirectUrl = getRequestPermissionsUrl($facebook);
    require_once(ABSOLUTE_DOCUMENTROOT_PATH.'do_redirect.inc.php');
    die();
}

// Let's see if we have an active session
if(!empty($_SESSION['facebookAuth']['facebookId']) && !empty($_SESSION['facebookAuth']    ['facebookUserObject'])){
    $facebookId = $_SESSION['facebookAuth']['facebookId'];
    $facebookUserObject = $_SESSION['facebookAuth']['facebookUserObject'];
}else{
    $facebookId = $facebook->getUser();

    if ($facebookId) {
        try {
            $facebookUserObject = $facebook->api('/me');
            // Put them in session so we can re-use them
            $_SESSION['facebookAuth']['facebookId'] = $facebookId;
            $_SESSION['facebookAuth']['facebookUserObject'] =     $facebookUserObject;
        } catch (FacebookApiException $e) {
            error_log($e);
        }
    }
}

// If no facebookId -> check permissions anyway
if(empty($facebookId)) {
    $redirectUrl = getRequestPermissionsUrl($facebook);
    require_once(ABSOLUTE_DOCUMENTROOT_PATH.'do_redirect.inc.php');
    die();
}

My function ‘getRequestPermissionsUrl’ calls for the getLoginUrl:

return $redirectUrl = $facebookObject->getLoginUrl(array('canvas'=>1,'fbconnect'=>0,'redirect_uri'=>$returnUrl,'scope'=>'publish_stream,email,user_likes'));

the file ‘do_redirect.inc.php’ does a js-redirect:

top.location.href = '$redirectUrl';

So, with that in mind let’s take a look at the first part.
This code gets included again after the user has denied the permission and the page reloads. In that case $_GET[‘error’] is filled and we’ll be redirected to another php-file in the app – a file that does not include the code I posted but has nothing to do with permissions or stuff at all. In that other file is a link to the page that needs permission again – the code above gets loaded again but when trying to request permissions I’m getting the error ‘something went wrong and we’re trying to fix it’ on a Facebook page.

I’ve tried evertyhing from destroying sessions to setting the accestoken empty to… you name it. I’m quite out of ideas now so I’d be glad if somebody of you guys have any suggestions. Any help would be greatly appreciated.

Thanks in advance!

  • 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-26T08:59:28+00:00Added an answer on May 26, 2026 at 8:59 am

    I just saw a newer question asking the same thing – Sorry, something went wrong after cancel application connexion on SDK 3.0

    There is a currently open bug in Facebook’s bug tracker about this

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

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I need to clean up various Word 'smart' characters in user input, including but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.