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

The Archive Base Latest Questions

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

Small problem here I want to make a small fb app which show different

  • 0

Small problem here
I want to make a small fb app which show different views for page admin and users, page admin can add html to the app and include the app in their page (somewhat like the old fbml app).

but the problem is when i’m authenticating the app it is jumping from page tab to its app page.

i need to acces the following things

[page] => stdClass Object 
(
    [id] => FAN_PAGE_ID
    [liked] => 1
    [admin] =>
)

for this i need to be in fb page tab while authenticating. How ? 🙁

i am posting my current code here.

please help me.

ob_start();
$app_id = "----------";
$app_secret = "-----------------";

include_once 'src/facebook.php';

$my_url = "http://apps.facebook.com/-----beta/index.php";

$facebook = new Facebook(array(
    'appId'  => $app_id,
    'secret' => $app_secret,
));

session_start();
$code = $_REQUEST["code"];
//echo $code . "</br>";

if(empty($code)) {
    $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
    $dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" . $app_id . "&display=popup&scope=manage_pages,email&redirect_uri=" . urlencode($my_url) . "&state=" . $_SESSION['state'];
    echo("<script> top.location.href='" . $dialog_url . "'</script>");
}

if($_REQUEST['state'] == $_SESSION['state']) {
    $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url) . "&client_secret=" . $app_secret . "&code=" . $code;
    $response = file_get_contents($token_url);
    $params = null;
    parse_str($response, $params);
    $graph_url = "https://graph.facebook.com/me?access_token=" . $params['access_token'];
    $user = json_decode(file_get_contents($graph_url));
    //echo $_REQUEST['signed_request'];echo "<hr>";
    //var_dump($user);

    $signedRequest = $facebook->getSignedRequest();
    $appData = array();
    if (!empty($signedRequest) && !empty($signedRequest['page'])) {
        $appData = json_decode($signedRequest['page'], true);
    }
    var_dump($appData); echo "<hr>";

    var_dump(parse_signed_request($_REQUEST['signed_request'] , $app_secret));

    echo("<hr>Hello " . $user->name);

}    
else {
    echo("The state does not match. You may be a victim of CSRF.");
}

function parse_signed_request($signed_request, $secret) {
    list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

    // decode the data
    $sig = base64_url_decode($encoded_sig);
    $data = json_decode(base64_url_decode($payload), true);

    if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
    error_log('Unknown algorithm. Expected HMAC-SHA256');
    return null;
}

// check sig
$expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
if ($sig !== $expected_sig) {
    error_log('Bad Signed JSON signature!');
    return null;
}

return $data;
}

function base64_url_decode($input) {
    return base64_decode(strtr($input, '-_', '+/'));
}
  • 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-26T17:27:47+00:00Added an answer on May 26, 2026 at 5:27 pm

    I am using this script in the tab:

        function parse_signed_request($signed_request, $secret) {
          list($encoded_sig, $payload) = explode('.', $signed_request, 2); 
          $sig = base64_url_decode($encoded_sig);
          $data = json_decode(base64_url_decode($payload), true);
    
          if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
            return null;
          }
          $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
          if ($sig !== $expected_sig) {
            return null;
          }
    
          return $data;
        }
    
        function base64_url_decode($input) {
          return base64_decode(strtr($input, '-_', '+/'));
        }
        $signed_request = $_REQUEST['signed_request'];
        $secret = $app_secret;
        $getdata = parse_signed_request($signed_request, $secret);
        $fanpage = $getdata['page'];
        $page_id = $fanpage['id']; // GET THE PAGE ID
        $is_fan = $fanpage['liked']; // 0 if its not fan, 1 if its fan
        $is_admin = $fanpage['admin']; //1 if user is admin of page. 0 if not
        if($page_id){
         //if app is tab
         if($is_admin){
          //if user is admin
         }
         if($is_fan){
          //I am fan
         }else{
          // I am not a fan
         }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a small app where I want absolute positioning - I can get
I want to make a page for android which is refreshing in every sec
Here's the problem: I'm trying to make a small reporting tool. So... I have
i have a small problem... i want to bind my app to adminsite. my
I am stuck with a small problem here.. What i am trying to do
I'm getting crazy with a small problem here, I keep getting an error and
Just a small SVN problem here. I setup my own SVN server Setting up
I have a small problem with interfaces. Here it is in Pseudo code :
So here is our problem: We have a small team of developers with their
Here's the problem -- I have a few thousand small text snippets, anywhere from

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.