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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:37:40+00:00 2026-05-25T22:37:40+00:00

I wrote a facebook app that works as a tab on a page. Here

  • 0

I wrote a facebook app that works as a tab on a page.

Here is my config.php file which contains the configuration and redirects to the authentication page if the user has not yet approved the app:

<?php
require_once("database.php");
require_once("functions.php");
require_once("facebook.php");

$config = array
(
    'database' => array
    (
        'host' => 'localhost',
        'name' => '***',
        'username' => '***',
        'password' => '***'
    )
);

$db = new Database($config['database']['host'], $config['database']['name'], $config['database']['username'], $config['database']['password']);
$db->connect();

$facebook = new Facebook(array(
    'appId' => '***',
    'secret' => '***',
    'cookie' => true
));

$user = $facebook->getUser();

if ($user)
{
    try
    {
        $me = $facebook->api('/me');
    } catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
    }
}

if ($user)
    $logoutUrl = $facebook->getLogoutUrl();
else
{
    $loginUrl = $facebook->getLoginUrl(array(
        'scope' => 'email,user_about_me,user_likes,user_status,read_stream,offline_access,publish_stream,publish_actions'
    ));
}

if (!$user)
{
    echo "<script type=\"text/javascript\">top.location.href = '".$loginUrl."';</script>";
}
?>

Here is my main file:

    <?php
    require_once("includes/config.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="he" lang="he" dir="rtl">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=windows-1255" />
        <title>
            שער 7 - הלב הצהוב | מכבי תל אביב
        </title>
    </head>
    <body>
        <?php
            $clLike = $facebook->api('/me/likes/204623816223540');
            if (!empty($clLike['data']))
                echo "I'm a fan!";
            else
                echo "I'm not a fan :(";
        ?>
    </body>
</html>

As I mentioned before, this app works as a tab on a facebook page and not as a stand-along facebook app, therefore there is no canvas url. The page tab url is: http://www.gate7.co.il/fbapps/predictor/ .

When a user enters the tab, he gets redirected to the authentication page (from the config.php), but when the authentication process is done, the user gets redirected to the page tab url (http://www.gate7.co.il/fbapps/predictor/) instead of the tab inside the page.

I tried to add these lines to the index file:

        <script type="text/javascript">
        if (top.location.href != "http://www.facebook.com/gate7yellowheart?sk=app_196175180456372")
            window.location = "http://www.facebook.com/gate7yellowheart?sk=app_196175180456372";
    </script>

It worked well on firefox, and the user got redirected from the page tab url to the actual tab in the page, but in chrome it just caused mess and showed facebook inside the tab.

What’s the solution for this?

  • 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-25T22:37:41+00:00Added an answer on May 25, 2026 at 10:37 pm

    In your getLoginUrl() call, set the redirect_uri param to your tab page, like this:

    $loginUrl = $facebook->getLoginUrl(array(
        'scope' => 'email,user_about_me,user_likes,user_status,read_stream,offline_access,publish_stream,publish_actions',
        'redirect_uri' => 'http://www.facebook.com/gate7yellowheart?sk=app_196175180456372'
    ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a Facebook app from PHP and HTML that work perfect in the
I have a serious problem in my app. I wrote a facebook like instant
I know it sounds weird but is there a way that an app (facebook
I'm developing an app for mobile phones that syncs the contacts with the facebook
I have built a Facebook app using OpenGraph that permits the users to write
I have a working Facebook app that most users will use just once. Leading
I am trying to make a simple Facebook app that takes some data from
I'm in the process of moving a PHP Facebook Webpage (App) I didn't originally
I want to write an Android app that given Facebook credentials logs in behalf
I have an app that I wrote a couple years ago that uses Canvas/FBML

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.