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

  • Home
  • SEARCH
  • 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 5978225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:29:00+00:00 2026-05-22T21:29:00+00:00

I have made a facebook application which when opened from apps.facebook.com/myapp points perfectly to

  • 0

I have made a facebook application which when opened from apps.facebook.com/myapp points perfectly to my domain’s index.php and can be seen in the facebook app window , but problem occurs when i try to redirect it to my register page ,it gets redirected to my domain , i want all the pages to be viewed in facebook app window . tried to use fb:redirect sdk function but site says they are going to deprecate these codes.

<?php
if(preg_match('/apps.facebook.com/',$_SERVER[HTTP_REFERER])){
    $app_id = '';
    $api_key = '';
    $app_secret = '';
    $canvas_page = 'mydomain/index.php';
    $auth_url = "http://www.facebook.com/dialog/oauth?client_id=".
    $app_id."&redirect_uri=".urlencode($canvas_page)."&scope=email,user_birthday,user_interests,user_about_me";
    $signed_request = $_REQUEST["signed_request"];
    list($encoded_sig, $payload) = explode('.', $signed_request, 2);
    $data = json_decode(base64_decode(strtr($payload,'-_', '+/')), true);
    if (empty($data["user_id"])){
        echo("<script> top.location.href='".$auth_url ."'</script>");
    }else{
        $canvas_page="mydomain/register.php";
        echo ("<script> top.location.href='".$auth_url."'</script>");
    }
}else{
    echo "No facebook";
}
?>

the code works perfectly up till echo("<script> top.location.href='" .$auth_url ."'</script>") when $canvas_page is the one set in facebook app dev form ; but gets redirected to some other page when $canvas_page is changed to my register.php page . where am i going wrong ?

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-22T21:29:01+00:00Added an answer on May 22, 2026 at 9:29 pm
    <?php
        //facebook application
        //set facebook application id, secret key and api key here
        $fbconfig['appid' ] = "123456392899383";
        $fbconfig['api'   ] = "97eb2asdfasdf3f20d4421b0fe8c1b2";
        $fbconfig['secret'] = "5c1d4asdfasdf71b59806b69c386b2ca";
    
        //set application urls here
        $fbconfig['baseUrl']    =   "http://www.your-url.com/";
        $fbconfig['appBaseUrl'] =   "http://apps.facebook.com/appname/"; 
    
        $uid            =   null; //facebook user id
    
        try{
            include_once "facebook.php";
        }
        catch(Exception $o){
            echo '<pre>';
            print_r($o);
            echo '</pre>';
        }
        // Create our Application instance.
        $facebook = new Facebook(array(
          'appId'  => $fbconfig['appid'],
          'secret' => $fbconfig['secret'],
          'cookie' => true,
        ));
    
        //Facebook Authentication part
        $session = $facebook->getSession();
        $loginUrl = $facebook->getLoginUrl(
                array(
                'canvas'    => 1,
                'fbconnect' => 0,
                'req_perms' => 'email,publish_stream,status_update,user_birthday,user_location,user_work_history'
                )
        );
    
        $fbme = null;
    
        if (!$session) {
            echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
            exit;
        }
        else {
            try {
                $uid      =   $facebook->getUser();
                $me     =   $facebook->api('/me');
                //PUT THE APPLICATION CODE HERE>
            } catch (FacebookApiException $e) {
                echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
                exit;
            }
        }
    
        function d($d){
            echo '<pre>';
            print_r($d);
            echo '</pre>';
        }
    ?>
    

    You can use this script to properly authorise the app an regular use it.

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

Sidebar

Related Questions

I have successfully made an facebook application which shows real time data from facebook
I have made an iframe style facebook application that uses php and javascript (jquery).
I have made an application which allows a user to login using their facebook
I have made a class which a form can inherit from and it handles
Hey all, I've made a facebook application for a contest, which allows users to
Hey!! I have made an application through which I am publishing an audio file
I am a facebook application developer and have made applications in the past. I
I have a website which uses http refer, and I have made a Facebook
I have made a Google login with OAuth2 and the PHP library which can
I made a Facebook Application that people use to share links from my webpage

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.