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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:21:41+00:00 2026-06-16T12:21:41+00:00

I got help from this post to figure out how to redirect to Facebook

  • 0

I got help from this post to figure out how to redirect to Facebook authorization page when someone access canvas page who has not yet authorized the app.

Now, I was expecting that after user authorizes the permissions FB will redirect to the canvas page (https://app.facebook.com/myapp). But it is redirecting to the canvas url (https://myhostingapp.com/game.php?...)

Is this expected or is there any thing we can do to control it. How do I tell the API to redirect to the canvas page after authorization?

Right now I am able to think of using the $_SERVER[HTTP_REFERER] to see if I am coming from authorization page and if yes the redirect the page to the canvas page again. But I am hoping there could be much better way of doing it

Canvas url code:

if (Config::$fbAvailalbe){ //see below how this variable is derived
    echo "fb is available";
    $facebook = new Facebook(array(
      'appId'  => Config::$appId,
      'secret' => Config::$appSecret,
    ));

    $user = $facebook->getUser();

    if ($user) {
        echo "app installed";
      try {
        // Proceed knowing you have a logged in user who's authenticated.
        $profile = $facebook->api('/me');
      } catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
      }
    }

    if (!$user) {
      echo " app not installed gonna redirect"; 
      $scope = "scope=email,read_stream,read_friendlists,publish_stream";
      $redirect = $facebook->getLoginUrl(
                    array(
                        'canvas' => 1,
                        'fbconnect' => 0,
                        'req_perms' => $scope
                        )
                    );
      echo '<script>top.location="' . $redirect . '";</script>';
      exit();
      //header("Location: $redirect".$scope);
    } 

    if ($profile){
        $firstName = $profile['first_name'];
        $sid = $profile['id'];
        var_dump($profile);
    }else{
        echo "unable to get profile";
    }

}else{

    echo "fb unavailable, using dmmy";
    $firstName = "Dummy Name";
    $sid = Config::$testsid;

}

Snipet from Config.php

    //this is to derive the $fbAvailable variable
    //we get this condition satisfied when we run the page runs from fb canvas 
    if (isset($_SERVER['HTTP_REFERER'])){

        if (substr_count($_SERVER['HTTP_REFERER'],'apps.facebook.com')){
            self::$fbAvailalbe = 1;
        }
    }
  • 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-06-16T12:21:43+00:00Added an answer on June 16, 2026 at 12:21 pm

    check documentation here.

    Two errors in the code

    Error#1:

    $scope = "scope = email,read_stream,read_friendlists,publish_stream";
    

    Error#2:

    As per the documentation here (as on now)

    req_params is ‘scope’

    Not sure about the ‘canvas’ and ‘fbconnect’ parameters which might be potentially ignored as they are not supported any more

    $redirect = $facebook->getLoginUrl(
                        array(
                            'scope' => $scope,
                            'redirect_uri' => 'https://app.facebook.com/myapp'
                            )
                        );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

9amI got help with the query from a previous post but I have a
Following help from this site I have now got my log in script largely
I got this RegEx from another post, but it doesn't fully function like it
I got this form working Ok but i can't figure out how to save
I've got this code from this post and everything is ok except one thing,
With some kindly help from StackOverflow, I've got Unity Framework to create my chained
I've got a python package which outputs considerable help text from: help(package) I would
Anyone, I need help, I got a task from my teacher, it's about jquery,
I just got help in how to compile this script a few mintues ago
can anybody help me solve this : i got $filename= index 198.php; i use

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.