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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:52:22+00:00 2026-05-27T10:52:22+00:00

I am trying to create a custom tab for a facebook page and it

  • 0

I am trying to create a custom tab for a facebook page and it works perfectly for me in firefox, chrome and internet explorer 8 in both the tab on the page and as a direct link but for others it just doesn’t pick up their like.

Here is my code:

require 'src/facebook.php';

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

$user = $facebook->getUser();


// alternative to the below but only works on the facebook tab itself
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);

if (empty($data["page"]["liked"])) {
echo "You are not a fan!";
} else {
echo "Welcome back fan!";
}

if ($user) {
try {
    $likes = $facebook->api("/me/likes/xxxxxxxxxx");
    if( !empty($likes['data']) )
    {
        ?>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script type="text/javascript">
        $(document).ready(function() {
            $('#fan').click(function() {
                $('#fan').animate({
                    opacity: 0.2,
                    width: 'auto',
                    height: 'auto'
                }, 1000, function() {
                    // Animation complete.
                    $('#fan').hide('slow');
                    $('#voucher').show('slow');
                });
            });
        });
        </script>

        <a href="#"><img id="fan" src="//www.website.com/facebook/2011/voucher/fans_image.jpg" alt="10% off" style="border:0;" /></a>
        <div style="display:none; position:absolute; top:0; left:0;" id="voucher" >
        <a href="//www.website.com/facebook/2011/voucher/EYE-TEST-DECEMBER-11.pdf" target="_blank"><img src="//www.website.com/facebook/2011/voucher/fb-voucher-dec11.jpg" style="border:0;" alt="10% off" /></a>  <br />
        <p style="text-align:center"><a href="//www.website.com/facebook/2011/voucher/EYE-TEST-DECEMBER-11.pdf" target="_blank">Click here to download PDF version of the voucher.</a></p>
        </div>
        <?php
    }
    else
    {
        ?>
        <img style="position:absolute; top:0; left:0; border:0;" id="all" src="//www.website.com/facebook/2011/voucher/fb_like_page.jpg" width="520" height="304" alt="Click LIKE button to get 10% off." />
        <?php
    }
} catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
    }
}

if ($user) {
    $logoutUrl = $facebook->getLogoutUrl();
} 
else {
    //user isn't logged in so just show un-liked image
    ?>
    <img style="position:absolute; top:0; left:0; border:0;" id="all" src="//www.website.com/facebook/2011/voucher/fb_like_page.jpg" width="520" height="304" alt="Click LIKE button to get 10% off." />
    <?php
    $loginUrl = $facebook->getLoginUrl(array(
        'scope' => 'user_likes'
    ));
}

More Info
The app is not in sandbox mode.

I was thinking that because the app appears in my account settings that is why it is only working for me but if I look at other fan-gated tabs, they don’t have the permissions notification pop up so that can’t be the case?

  • 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-27T10:52:22+00:00Added an answer on May 27, 2026 at 10:52 am

    The persmissions notification is for people explicitly authorising an app which is what you appear to have done. You are showing info to people who have and haven’t authorised your application, not to people who have or haven’t liked your page

     // alternative to the below but only works on the facebook tab itself
     $signed_request = $_REQUEST["signed_request"];
     list($encoded_sig, $payload) = explode('.', $signed_request, 2);
     $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
    
      if (empty($data["page"]["liked"])) {
      echo "You are not a fan!";
      } else {
      echo "Welcome back fan!";
      }
    

    The code here is what I would expect for people who like or don’t like the page tab. This has nothing to do with authorising your application that sits on that tab. When a user likes your page, you don’t get access to their user id etc, only if they like the page. But your code seems to be using the api to test if a user likes the page. My guess is that your user object is actually null, as the user hasn’t explicitly authorised the application on that page tab. Does that make sense?

    So unless they’ve granted access to the app:

    if ($user) {
    $logoutUrl = $facebook->getLogoutUrl();
    } 
    else {
    //user isn't logged in so just show un-liked image
    ?>
    <img style="position:absolute; top:0; left:0; border:0;" id="all" src="//www.website.com/facebook/2011/voucher/fb_like_page.jpg" width="520" height="304" alt="Click LIKE button to get 10% off." />
    <?php
    $loginUrl = $facebook->getLoginUrl(array(
        'scope' => 'user_likes'
    ));
    }
    

    $user will be null here and you will be telling people to like your page whether they have or haven’t done so

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

Sidebar

Related Questions

I am trying to create a custom tab for a facebook page and it
I'm trying to create a simple iFrame custom tab on my fan page. I'm
I am trying to create a custom accordion for my page to that display
I'm trying to create a custom tab navigator that has to look like this
I am trying to create custom background selector for my ExpandableListView. It works fine
i am trying to create a custom tab in my android app and i
I am trying to create a custom tab in my Build reports. I followed
Im trying to create a custom version of the RequiredAttribute to replace the built
I'm trying to create a custom JSP tag that would take an array object
I'm trying to create a custom transition, to serve as a replacement for a

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.